Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Intro to Java Programming For this exercise, we will create the SequenceReader program and hand in SequenceReader.java. The purpose of SequenceReader is to allow the
Intro to Java Programming
For this exercise, we will create the SequenceReader program and hand in SequenceReader.java. The purpose of SequenceReader is to allow the user to enter the name and length of an alphabet, the alphabet, and then a sequence of alphabet symbols terminated by an empty line. A sample is shown below:
To create SequenceReader, code and test the following incrementally:
- A void method readAlphabet() that allows the user to enter the name, length, and symbols for an alphabet. (Since we don't know arrays yet, we won't bother to store the symbols. Extra credit is available if you do use an array of Strings to store the symbols.)
- A value method readSequence() that allows the user to enter a sequence of arbitrary length, one symbol at a time. After the user has entered a symbol, the program will ask the user if they would like to enter another symbol. The user may enter yes or no in response to that question, and the program will act accordingly. The method should return the length of the sequence entered by the user. Make sure you understand this is a value method returning an int!
Note that both methods require loops, and that the optimal choice of which kind of loop is different for each method.
Some sample output from a run of my program: What is the name of the sequence alphabet? RNA How many "letters" are in the sequence alphabet for RNA? 4 What is the next letter in RNA? A What is the next letter in RNA? C What is the next letter in RNA? G What is the next letter in RNA? U Please enter a sequence with one element per line Will you enter another element? (yeso) yes Will you enter another element? (yeso) yes Will you enter another element? (yeso) yes Will you enter another element? (yeso) no Thank you. The sequence is 4 items longStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started