hey community, I'm working on the final component of my assignment and cant figure out how to do a calculation in regards to applying discounts. For my assignment I need to apply a 10% discount on each unit brought in groups of 5. So for example If a purchase was made for 17 DVD-RW+ drives which have a unit price of $30.00 each, then the multi buy discount would apply to the first 15 items (3 groups of 5) and the discount calculation would be: so 10% of $30.00 is $3 X $15 which is a $45.00 discount, but I cant figure out how to program it, i need the discount value to be displayed on the screen, my code so far is
if (menuChoice == 'C' || menuChoice == 'c') { // Product and price information entry System.out.println("Welcome to Tabular sales summary"); System.out.println(); System.out.print( " Please enter product code : "); productCode = scanner.nextLine(); System.out.println(); System.out.print("Enter product description : "); productDescription = scanner.nextLine(); System.out.println(); System.out.print("Please enter unit price : "); unitPrice = scanner.nextDouble(); System.out.println(); System.out.print("Please enter ammount of units purchased : "); quantityPurchased = scanner.nextInt(); System.out.println(); System.out.print("Salesperson : "); salesPerson = charInput.readLine(); System.out.println(); //Layout of recept System.out.print( "Prod. code "); System.out.print("Product Description "); System.out.print("Unit Price "); System.out.print("Qty "); System.out.println("Total"); System.out.print("----------- "); System.out.print("------------------------- "); System.out.print("------------- "); System.out.print("------ "); System.out.println("------"); //Calculations for display subTotal = unitPrice * quantityPurchased; }
If anyone could help me I would be very thankful