Assignment 9
Due Friday, May 15 at 11:59pm on Canvas


Important: You must only use concepts and methods taught in class to complete this assignment - or you will receive a 0 on this assignment


Pair Programming (Required - or You Will Get a 0)
  • Both partners fill in, sign, date, and submit the pair programming contract
  • Upload the document(s) along with your assignment code to Canvas.
  • Please make sure both your names are on your file (hint: use a comment).
  • If you need help finding a partner, please contact me as soon as possible.


Assignment 9.1: Java Jive Pastries and Cafe (10 pts)

  • Open a new class called Pastries.java.
  • This program will simulate an online pastry business and display a receipt to the customer who has placed an 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.
  • Additionally, for full credit, please use final variables to store the price of each pastry. For example:
final double PRICE_ECLAIR = 3.95; //use all CAPS for the names of final variables
  • When your program output works as shown below (including proper formatting of the output), submit Pastries.java to Canvas
  • Note: Listen to the Java Jive song here.

Sample Output:

Welcome to Java Jive Pastries and Cafe!
Allow me to assist you with your order.

We sell the following desserts:
Mocha Eclairs -- $3.95 each
Cocoa Cookies -- $2.50 each
Coffee Cake -- $5.50 per slice
Java Jive Brownies -- $4.50 each

Please enter the number of Mocha Eclairs: 3
Please enter the number of Cocoa Cookies: 12
Please enter the number of slices of Coffee Cake: 1
Please enter the number of Java Jive Brownies: 5

You Ordered the Following:
Mocha Eclairs: 3 @ 3.95 each...            $11.85
Cocoa Cookies: 12 @ 2.50 each...           $30.00
Coffee Cake: 1 @ 5.50 each...              $5.50
Java Jive Brownies: 5 @ 4.50 each...       $22.50

Total:                                     $69.85

Thank you for your order! Please come again!


  • Note that \t is not a perfect solution for lining up the output in the case of every numerical input. Just do the best you can, and don't worry if something like a single digit number throws off your alignment.