Assignment 9
Due Tuesday, October 30 at 9:20am 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: What's Your Sign? (10 pts)


Venice ast sm.jpg

  • For this assignment, let's write an astrology program.
  • Welcome the user (see sample output below)
  • Prompt the user to enter a numerical value (1-12) for the month of his/her birth (see sample output)
  • Prompt the user to enter a numerical value (1-31) for the day of his/her birth (see sample output)
  • Using the chart below for the astrological signs, determine the user's sign based on his or her input.
  • Expect to need to use if, else if and else statements.
  • Expect to use logical operators (&&, ||).
  • Submit your source code in a file called Sign.java to Canvas when finished    

Aries             March 21-April 19
Taurus            April 20-May 20
Gemini            May 21 - June 21
Cancer            June 22 - July 22
Leo               July 23 - August 22
Virgo             August 23 - September 22
Libra             September 23 - October 22
Scorpio           October 23 - November 21
Sagittarius       November 22 - December 21
Capricorn         December 22 - January 19
Aquarius          January 20 - February 18
Pisces            February 19 - March 20


Your sample output must be identical to mine:

What's your sign?
Please enter the month of your birth (1-12): 3
Please enter the day of your birth (1-31): 3
Your Sign is Pisces.


Alternately,

What's your sign?
Please enter the month of your birth (1-12): 4
Please enter the day of your birth (1-31): 12
Your Sign is Aires.


Alternately,

What's your sign?
Please enter the month of your birth (1-12): 100
Please enter the day of your birth (1-31): -2
Invalid Entry. Please run the program to try again.