Assignment 9
Due Tuesday May 15 at 1:20pm on Canvas


Assignment 9.1: Making a Receipt (10 pts)
  • Let's write a program to create a receipt.
  • Open a new project in Eclipse called Cookies and create a new class called Cookies.java.
  • This program will simulate an online cookie business and print out a receipt to the customer for their order.
  • 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 Java Cookies!
    Allow me to assist you with your order.

    We sell the following flavors:
    Mocha Cookies -- $1.95 each
    Cocoa Cookies -- $2.15 each
    Coffee Chai Cookies -- $2.05 each
    Java Cookies (Chocolate Chocolate Chip with Macadamia) -- $1.85 each

    Please enter the number of Mocha Cookies: 3
    Please enter the number of Cocoa Cookies: 2
    Please enter the number of Coffee Chai Cookies: 5
    Please enter the number of Java Cookies: 1

    You Ordered the Following:
    Mocha Cookies: 3 @ $1.95 each...            $5.85
    Cocoa Cookies: 2 @ $2.15 each...            $4.30
    Coffee Chai Cookies: 5 @ $2.05 each...      $10.25
    Java Cookies: 1 @ $1.85 each...             $1.85

    Total:                                      $22.25

    Thank you for your order! Please come again!


Assignment 9.2 Grade Values

  • 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 class file named LetterGrade.java, ask 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.

    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 when you are finished.


Assignment 9.3: Days in a Month (10 pts)
  • Develop a program that first asks the user to enter a month (January, 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 user should be able to enter upper or lower case letters for the days of the month and the program should still recognize the entry month.
  • The name of the Java project for this program should be MonthDays.
  • Submit MonthDays.java when finished.

    Be careful of the spelling, including capitalization, as you will lose points for a misspelled name.

  • 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): September
30 days

Alternately:

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


Alternately:

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

Hint: Thirty days hath September