Use your previous working Java program as a starting point (Project 3). Create another function that determines whether the customer should receive a discount. Assume your food truck gives a 10% discount on orders over $50 (the total BEFORE tax). If the order is eligible for a discount, then calculate and display the discount. If the order does not get a discount, then still display the discount, but it should be 0. Include a line before this that tells every customer that your business gives a 10% discount on all orders over $50 so they understand this part of their receipt.   You will also create two classes, one for existing project two called foodTrack and another class called foodDiscount that extends foodTrack.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question

Use your previous working Java program as a starting point (Project 3). Create another function that determines whether the customer should receive a discount. Assume your food truck gives a 10% discount on orders over $50 (the total BEFORE tax). If the order is eligible for a discount, then calculate and display the discount. If the order does not get a discount, then still display the discount, but it should be 0. Include a line before this that tells every customer that your business gives a 10% discount on all orders over $50 so they understand this part of their receipt.

 

You will also create two classes, one for existing project two called foodTrack and another class called foodDiscount that extends foodTrack.

 

This is project 3:

//initialize program
import java.util.Scanner;

public class Main
{
finalstatic String items[]=new String[]{"FRIES","CHEESESTEAK","BISCUIT","SALADBOWL","DONUTBOX","SALESTAX"};
finalstaticfloat price[]=newfloat[]{2.99F,5.99F,.99F,5.99F,10.99F,.06F};//declare array functions and variables
staticfloat subTotal=0, TAX=0, total=0, tender=0,change=0;
 
publicstaticvoid getInput(int[] ordered_items)
{
Scanner sc= new Scanner(System.in);
for(int i=0;i<5;i++)
{//get input from the userand showcase price and per item as well as quantity
//ask the user questions
System.out.println("How many "+ items[i] +" would you like to order? (each at: " + price[i] + ")");
ordered_items[i] = sc.nextInt();
}
}


 
publicstaticvoid billCalculator(int[] ordered_items,float[] item_bill)
{
for(int i=0;i<5;i++)//calculate for the itemsor dered
{
item_bill[i] = ordered_items[i]*price[i];
}
for(int i=0;i<5;i++)//calculate the price for the items ordered
{
subTotal+=item_bill[i];
}//calculate subtotal and total
TAX = subTotal * price[5];
total = subTotal + TAX;
}
 


publicstaticvoid printBill(int[] ordered_items,float[] item_bill)
//Receipt displayal starts here
{
System.out.println("\t\t\t\t\t\tTop Cuisine");
System.out.println("\t\t\t\t\t\t1267 Loongton st.");
System.out.println("\t\t\t\t\thyattsville, Maryland 28746");
System.out.println("\t\t\t\t\t\t301-273-378");
 
for(int i=0;i<5;i++)
{
System.out.println(ordered_items[i] + " " + items[i] + " each at: $" + price[i] + "\t\t\t\t\t\t\t\t $" + item_bill[i]);
}
 
 
//Display items quantity ordered, and cost per individual item
//start displaying the total , taxes, subtotal and change.
 
System.out.println(" Subtotal :\t\t\t\t\t\t\t\t\t\t\t\t$"+subTotal );
System.out.println(" Taxes : \t\t\t\t\t\t\t\t\t\t\t\t$" +TAX);
System.out.println(" Total :\t\t\t\t\t\t\t\t\t\t\t\t$"+total);
System.out.println(" Tender :\t\t\t\t\t\t\t\t\t\t\t\t$" +tender);
System.out.println(" Change :\t\t\t\t\t\t\t\t\t\t\t\t$" +change);
System.out.println("\t\t\t\t Thank You For Visiting ! Come Again!");
}

 
//displya total amount due to user if not met, loop back until price is correctly payed.
publicstaticvoid main(String[] args)
{
int ordered_items[]=newint[5];
float item_bill[]=newfloat[5];
getInput(ordered_items);
billCalculator(ordered_items, item_bill);
System.out.println("How much will you be paying ? (Total is " + total + ")");
Scanner sc= new Scanner(System.in);
while(true)
{
tender = sc.nextFloat();
if(tender<total)
{
System.out.println("You are paying "+(total-tender)+" less than the total bill");
System.out.println("Please re-enter the amount");
}

else
{
break;
}
}
change = tender - total;
printBill(ordered_items, item_bill);
}
}
//program finished.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT