this is my assignment
Requirements
The software you developed in the previous exercise must be extended to allow for the application of a 10% discount on purchases over $50. When a transaction’s sub-total before tax is equal to or greater than $50, the cashier should be given the opportunity to apply the discount to the purchase. GST is then to be applied to the adjusted sub-total. A sample transaction is shown below:
Program Output [Sample applied discount]
**********************************
****** Maria’s Bakeshop ******
**********************************
Begin Transaction
Enter the product name: Sweet Cakes
Enter the quantity: 30
Enter the product price: $2.75
Apply 10% discount (y/n)? Y
PRODUCT: Sweet Cakes
SUB-TOTAL: $82.5
DISCOUNT: -$8.25
GST: $3.71
TOTAL: $77.96
Transaction End
Program Output [Sample denied discount]
**********************************
****** Maria’s Bakeshop ******
**********************************
Begin Transaction
Enter the product name: Sweet Cakes
Enter the quantity: 30
Enter the product price: $2.75
Apply 10% discount (y/n)? n
PRODUCT: Sweet Cakes
SUB-TOTAL: $82.5
GST: $4.12
TOTAL: $86.62
Transaction End
Program Output [Sample without discount]
**********************************
****** Maria’s Bakeshop ******
**********************************
Begin Transaction
Enter the product name: Bread
Enter the quantity: 5
Enter the product price: $0.99
PRODUCT: Bread
SUB-TOTAL: $4.95
GST: $0.24
TOTAL: $5.19
Transaction End
Technical Specifications
The technical specifications of the extensions to the program are as follows:
The program will utilize constants where appropriate
The program will prompt the user for the following:
To apply discount if sub-total is $50 or more
Display a message if the discount is not applied for sub-totals of $50 or more
The program will display the following
Discount amount (calculated value) if a discount was applied
When prompting for whether or not to apply a discount, ensure that both uppercase and lowercase responses are handled properly
All program code must conform to best practices and coding standards
Optional Requirement
this is the code i have, all i need to know is how i can make the user imput matter, everythign works but when i hit "n" on user imput it still shows my discount how do i make it so when i hit "n" it doesnt do the calculation or show it. ive tired everything and its not working please help
/*
Author:Ryan
Date:09/18/2012
Purpose: A program to allow the bakery to process a transaction as well as a discounted price,
per amount allocated for specified minimum amount has been reached (50$)
*/
import java.util.Scanner;
public class MariaBakery {
public static void main(String args[]) {
// local variables
String productName = "";
double price = -1.0;
double gstAmount = -1.0;
double totalPrice = -1.0;
int quantity = 1;
double subTotal = -1.0;
String discount = "0";
double discountAmount = -1.0;
// DISCOUNT rate
final double DISCOUNT = .10;
// tax rate
final double GST_RATE = 0.05;
// Define a scanner for keyboard input
Scanner in = new Scanner(System.in);
// Display the title
System.out.println("****************************** ****");
System.out.println("****** Maria's Bakeshop ******");
System.out.println("****************************** ****");
System.out.println("\nBegin transaction\n");
System.out.print("Enter the product name : ");
productName = in.nextLine();
System.out.print("Enter the quantity : ");
quantity = Integer.parseInt(in.nextLine());
System.out.print("Enter the product price : $ ");
price = Double.parseDouble(in.nextLine());
// perform calculations
gstAmount = (price * quantity * GST_RATE);
subTotal = (price * quantity);
discountAmount = (subTotal * DISCOUNT);
totalPrice = (quantity * price) + gstAmount - discountAmount;
// Make Decison
if (totalPrice >= 50) {
System.out.println("Apply 10% discount (y/n)?");
discount = (in.nextLine());
} else {
System.out.println(" ");
}
// display output
System.out.println("\nProduct: " + productName);
System.out.println("Sub total: $ " + subTotal);
if (totalPrice >= 50) {
System.out.println("Discount: $-" + discountAmount);
}
System.out.println("Gst Amount: $ " + gstAmount);
System.out.println("Total Price: $ " + totalPrice);
System.out.println("\nTransaction End");
}
}