Assignment 9
Due Tuesday, May 15 at 9:20am on Canvas



Assignment 9.1: Days in a Month (10 pts)
  • Develop a program that first asks the user to enter a month (1 for January, 2 for February, and so on) and then prints the number of days in the month followed by the word "days". For February, print the phrase "28 or 29 days".
  • The name of the source code file for this program must be monthdays.cpp and all your code must be in this file.
  • Submit your program to Canvas when finished.
  • Your program must operate like this, such that the same sequence of inputs produces the same output:

I will print the number of days in a month.
Enter the month (1-12): 9
30 days

Alternately:

I will print the number of days in a month.
Enter the month (1-12): 2
28 or 29 days


Alternately:

I will print the number of days in a month.
Enter the month: 1
31 days

Hint: Thirty days hath September


Assignment 9.2: Grade Values (10 pts)

  • Academic grades in the US are traditionally given as letter grades: A, B, C, D, and F. We need to translate these letter grades into number to calclulate a grade point average (GPA).
  • Write a program that converts a letter grade into it's numerical value using the following conversion table.
    Letter Grade GPA
    A 4.00
    A- 3.67
    B+ 3.33
    B 3.00
    B- 2.67
    C+ 2.33
    C 2.00
    C- 1.67
    D+ 1.33
    D 1.00
    D- 0.67
    F 0.00
  • In a file named letterGrade.cpp, prompt the user for a letter grade of A, B, C, D, or F, possibly followed by a + or -, and no other input as shown in the Example Run.
  • Convert the letter grade into the numerical equivalent shown above using a series of if statements.

    Notice that the highest number is 4.0 and that there are no F+ or F- grades. Make sure that the highest grade number is 4.0 and that F+, F and F- are assigned 0.0 values.

  • Display the output using the default formatting and precision for the numbers -- do NOT add any numerical formatting statements to the code.
  • Sample Output: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.
    Enter a letter grade: B-
    The numeric value is 2.67
    
    Enter a letter grade: A+
    The numeric value is 4.0
    
    Enter a letter grade: F-
    The numeric value is 0.0
    

    In the above three example runs, the user entered "B-", "A+" and "F-" (without the quotes) as the letter grades to convert.

  • After displaying the output, exit the program.
  • Submit your program to Canvas when you are finished.

Assignment 9.3: Making a Receipt (10 pts)
  • Let's write a program to create a receipt.
  • Open up your pastries.cpp from Assignment 5.
  • Your output should look identical the following (except the user input will vary).
  • Notice the blank lines. These are important, so don't forget to include them!
  • The program should follow the exact formatting shown below, including spacing and indentation.
    • Hint: Remember "\t"?
  • Note that you will need to print out exactly 2 decimal places for the dollar values.
  • When you are finished, submit your program.


    Welcome to C++ Pastries!
    Allow me to assist you with your order.

    Please enter the number of eclairs: 3
    Please enter the number of bear claws: 2
    Please enter the number of croissants: 5
    Please enter the number of cupcakes: 1

    You Ordered the Following:
    Eclairs: 3 @ $1.95 each...                  $5.85
    Bear Claws: 2 @ $2.15 each...               $4.30
    Croissants: 5 @ $2.05 each...               $10.25
    Cupcakes: 1 @ $1.85 each...                 $1.85

    Total:                                      $22.25

    Thank you for your order! Please come again!