Part B: [5 pts] Read the description for program 2A. Instead of making sample runs, this week you must figure out minimally how many different test cases you will need to really be sure that your program works the way it is supposed to. Write down how many, and explain why you chose that number and what the different types of cases are.
Part C: [10 pts] Write pseudocode for a program that will take a binary (base 2) number and convert it to a base 10 decimal, displaying the result. If you have no idea how to do this, see these approaches: http://www.wikihow.com/Convert-from-Binary-to-Decimal. Make your pseudocode fairly detailed, like our GPA example, but do NOT write Java code.
Submission: Type up your answers for parts B and C in a plain text file called w2.txt and submit on Blackboard before the 6pm deadline. Late assignments will not be accepted.
Part A: Subsequence Search [15 pts]
The purpose of this program is to perform a limited variation of a problem that occurs in computational genomics, finding a spliced motif. DNA sequences are strings consisting of 4 characters, 'A, 'C', 'T', and 'G'. A subsequence of a string is a collection of characters contained in order in the string, but not necessarily contiguously. For example "ACG" is a subsequence of "AAAGGTACCAATTGAGT" because you can find a set of indices (several such sets actually) in which the characters ACG occur in that order within the string, such as {0, 7, 13}. This is different from being a substring, in which the characters must appear in order next to each other. (Reference: this problem was adapted from http://rosalind.info/problems/sseq/.)
Your program must get two strings from the user: the first can be of any length, and the second should have exactly three characters. First check whether the second input has exactly three characters. If not, then do not do any further processing. If it does have three characters, then your program must determine whether the second input is a subsequence of the first input. If it is, then display the earliest indices where the three characters may be found in order within the first string. In the example above, {0, 7, 13} is the earliest set of indices, whereas {2, 8, 15} would be another one. If it isn't a subsequence, then just say so.
This problem can be solved using appropriate String methods and decision statements. Loops are not necessary. I recommend thinking this through in pseudocode first, and then figuring out which String methods will help you implement the pseudocode. Note that your program does not have to verify whether either string is a valid DNA sequence. Instead, it will solve a more general problem for determining whether any 3 character code is a subsequence of another string. Name your class and file pg2a and submit as usual (see below).
Part B: Spring Break [30 pts]
This program will price out various vacation options for your spring break. There are five destinations to choose from, each with prices for lodging (per person, per night). Some destinations give discounts for multiple nights, and others for groups. The details are given in the table below.
| Destination | Lodging | Discount |
|---|---|---|
| Miami | $123.99 | 10% if stay is more than 5 nights |
| New Orleans | $95.00 | 15% for at least 10 people |
| New York City | $180.50 | $20 per person per night for more than 8 people or at least 8 nights |
| San Diego | $212.15 | 5% if stay is at least 3 nights |
| Cancun | $110.90 | 8% if 10-20 people inclusive and the stay is 7-10 nights inclusive |
Your program must get input for the following trip details:
Implementation Details: You are expected to check for input validity, and only process valid inputs. Also, you are expected to use named constants (final) for all the values that are part of the problem statement. All monetary values must be displayed with exactly two digits after the decimal point. Name your file pg2b and submit as usual (see below).
General assignment requirements, style and submission details: