Starting from:

$30

CS31- Assignment 2 Solved


a


You can test your understanding of the royalty schedule by experimenting with this royalty calculator.

Your program must collect the information for one movie in the manner indicated by the examples, and then write to cout a line with three hyphens only (no spaces or other characters), followed by exactly one line in a format required below. Our grading tool will judge the correctness of your program by examining only the line following the line with three hyphens. That line you write must be in one of the following five forms; the text must be identical to what is shown, except that italicized items are replaced as appropriate:

If the number of units sent is negative:    The number of units sent must be nonnegative.

If an empty string was provided for the title:    You must enter a title.

If the base price is negative:    The base price must be nonnegative.

If the premium status is not y or n (must be lower case):    You must enter y or n.

If the input is valid and none of the preceding situations holds:

   title earned $amount in royalties.

In the last case, title must be the title as entered, and amount must be the correct answer, shown as a number with at least one digit to the left and exactly two digits to the right of the decimal point, rounded to the nearest cent. (See pp. 32-33 in the Savitch book.) The lines you write must not start with any spaces. If you are not a good speller or typist, or if English is not your first language, be especially careful about duplicating the messages exactly. Here are some foolish mistakes that may cause you to get no points for correctness on this project, no matter how much time you put into it:

Not writing to cout a line with exactly three hyphens in all cases.

Writing any spaces on the line that is supposed to have three hyphens.

Writing more than one line after the line with three hyphens. Don't, for example, add a gratuitous "Report royalty income on Schedule E." Writing lines to cerr instead of cout. Writing lines like these:

                             The Martian urned $123.40 in royalties.   misspelling

                             The Martian Earned $123.40 in royalties.  wrong capitalization

                             The Martian earned $123.40.               missing text

                             The Martian earned $ 123.40 in royalties. extra space

                             The Martian earned 123.40 in royalties.   missing dollar sign

                             The Martian earned $123.40 in royalties   missing period

                             The Martian earned $123.400 in royalties. extra digit

                             The Martian earned $123 in royalties.     missing decimal point and digits

Your program must gather the units sent, the title, the base price, and the premium status in that order. However, if you detect an error in an item, you do not have to request or get the remaining items if you don't want to; just be sure you write to cout the line of three hyphens, the required message and nothing more after that. If instead you choose to gather all input first before checking for any errors, and you detect more than one error, then after writing the line of three hyphens, write only the error message for the earliest erroneous input item.

You will not write any loops in this program. This means that each time you run the program, it handles only one

https://www.coursehero.com/file/12707090/CS-31-Project-2-Fall-2015/

movie. It also means that in the case of bad input, you must not keep prompting the user until you get something acceptable; our grading tool will not recognize that you're doing that.

A string with no characters in it is the empty string. A string with at least one character in it is not the empty string, even if the only characters in it are things like spaces or tabs. Although realistically it would be silly to have a title consisting of seventeen spaces and nothing more, treat that as you would any other non-empty string: as a valid title. (Since you don't yet know how to check for that kind of situation anyway, we're not requiring you to.)

The one kind of input error your program does not have to deal with (because you don't yet know enough to know how to do this nicely) is the case of not finding a number in the input where a number is expected. Our grading tool will not, for example, supply the text too much when your program requests the base price. You do not have to deal with not finding an integer in the input for the units sent; our tool will not, for example, supply 838.7 for the units sent.

The correctness of your program must not depend on undefined program behavior. Your program could not, for example, assume anything about n's value at the point indicated:

                   int main()

                   {

                       int n;

                       int m = 42 * n;  // n's value is undefined

                       …

What you will turn in for this assignment is a zip file containing these three files and nothing more:

1.     A text file named royalty.cpp that contains the source code for your C++ program. Your source code should have helpful comments that tell the purpose of the major program segments and explain any tricky code.

2.     A file named report.doc or report.docx (in Microsoft Word format) or report.txt (an ordinary text file) that contains:

a.    A brief description of notable obstacles you overcame. (In Project 1, for example, some people had the problem of figuring out how to work with more than one version of a program in Visual

C++.)

b.    A list of the test data that could be used to thoroughly test your program, along with the reason for each test. You don't have to include the results of the tests, but you must note which test cases your program does not handle correctly. (This could happen if you didn't have time to write a complete solution, or if you ran out of time while still debugging a supposedly complete solution.) For Project 1, for example, such a list, had it been required, might have started off like this:

More surveyed than the total for keeping and returning (1000, 413, 382 )

Fewer surveyed than the total for keeping and returning (500, 413, 382 ) Zero surveyed (0, 100, 100)

Data giving a non-integer percentage (1000, 413, 382)

More reponses for keeping than returning (1000, 413, 382)

Equal reponses for keeping and returning (1000, 500, 500)



3.     A file named hw.doc or hw.docx (in Microsoft Word format) or hw.txt (an ordinary text file) that

https://www.coursehero.com/file/12707090/CS-31-Project-2-Fall-2015/

contains your solution to the homework accompanying Project 2.

Powered by TCPDF (www.tcpdf.org)

More products