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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education