Assignment 15
Due Tuesday, June 9 at 11:59pm on Canvas
Important:
To receive credit, you must only use concepts and methods taught in
class to complete these assignments - or you will receive a 0
Pair Programming Required (or You Will Receive 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.
- No extra credit if you do not submit the contract along with your 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 15: Ice Cream Truck (10 pts)
- In this program, you will write a menu program for an ice cream truck.
- Name your program IceCream.java
- For this program, you will need to write 3 methods, as follows:
dispayTotal
- Takes a double parameter for the total food price.
- Takes another double parameter for the percent tip
- calls the calculateTax method to add taxes to the price.
- calls the calculateTip method to add the tip to the price.
- Displays the price to two decimal places along with the message "With taxes and tip, your total comes to $<price>"
- returns nothing
calculateTax - Takes in a double parameter for the subtotal for the food.
- Calculates the tax, assuming the tax rate is 9.25% in San Jose
- adds the tax onto the the total price,
- returns the update price
calculateTip
- Takes in a double parameter for the current bill (price of food + tax).
- Takes in a second double parameter for the percent tip
- Calculates the tip and adds the tip onto the the total price
- returns the updated price
Additional Specifications
- Each method must also have a full Javadoc comment in the style described in class or you will lose 3 points.
- Important: You should call the displayTotal method inside of main, not the other two methods.
- The other 2 methods should be called inside of the displayTotal method.
- Hint: calculateTip will work very similarly to the calculateTax method
- Note:
If the user does not select option A, B, or C for the tip, you should
automatically assign a tip of 20% (as shown in the second sample output
below).
Starter Code:
/** * @author FILL IN YOUR NAME HERE * @author FILL IN YOUR NAME HERE * CIS 36A */ import java.util.Scanner; public class IceCream { public static void main(String[] args) { Scanner input = new Scanner(System.in); int numChoc; int numVan; int numStraw; final double PRICE_CHOC = 3.50; final double PRICE_VAN = 3.25; final double PRICE_STRAW = 3.15; final double SUBTOTAL, TIP; String choice; System.out.println("Jingle Jingle! Place Your Order Here!\n"); System.out.print("Enter the number of chocolate: "); numChoc = input.nextInt(); System.out.print("Enter the number of vanilla: "); numVan = input.nextInt(); System.out.print("Enter the number of strawberry: "); numStraw = input.nextInt();
//Add more code here!
System.out.println("Thank you! Please come again!"); }
//Write your methods AND JAVADOC COMMENTS here
}
Sample Output- Your program should work identically to the following:
Jingle Jingle! Place Your Order Here!
Enter the number of chocolate: 4 Enter the number of vanilla: 3 Enter the number of strawberry: 2
Would you like to tip:
A: 10% B: 15% C: 20%
Enter your choice: B You chose 15%
With taxes and tip, your total comes to $37.75
Thank you! Please come again!
Jingle Jingle! Place Your Order Here!
Enter the number of chocolate: 1 Enter the number of vanilla: 0 Enter the number of strawberry: 5
Would you like to tip:
A: 10% B: 15% C: 20%
Enter your choice: Z You chose 20%
With taxes and tip, your total comes to $25.24
Thank you! Please come again!
- When your program works as shown above, submit it to Canvas.
|
|