Question
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub // creating the scanner sc . Scanner sc
import java.util.Scanner;
public class Main {
public static void main(String[] args) { // TODO Auto-generated method stub
// creating the scanner sc . Scanner sc = new Scanner(System.in); // declaring the prices of the products as the constant. final double BREAD = 1.40; final double CHICKEN = 2.75; final double CHIPS = 3.30; final double COOKIES = 2.60; final double SALES_TAX = 6; // declaring the quantity of items an an integer. int noBread, noChicken, noChips, noCookies; // declaring the various costs and taxes as a decimal. double totalBread, totalChicken, totalChips, totalCookies, subTotal, tax, grandTotal; System.out.printf(" "); System.out.println("Welcome to the market! Please see our items below. "); System.out.printf("%-15s $%.2f/loaf ", "Bread" , BREAD); System.out.printf("%-15s $%.2f/lb ", "Chicken" , CHICKEN); System.out.printf("%-15s $%.2f/bag ", "Chips", CHIPS ); System.out.printf("%-15s $%.2f/box ", "Cookies", COOKIES ); // providing the prompt statement for the customer to enter the quantity of the items. System.out.print(" How many loafs of bread would yoou like? "); noBread = sc.nextInt(); System.out.print("How many pounds of chicken would yoou like? "); noChicken = sc.nextInt(); System.out.print("How many bags of chips would yoou like? "); noChips = sc.nextInt(); System.out.print("How many boxes of cookies would yoou like? "); noCookies = sc.nextInt(); System.out.println(" "); System.out.println(" --------------------------------------------------------------------------------------- "); System.out.println(" Thank you for shopping with us! Please find your recipt below. "); System.out.printf(" "); // processing the cost of each item bought. totalBread = BREAD * noBread; totalChicken = CHICKEN * noChicken; totalChips = CHIPS * noChips; totalCookies = COOKIES * noCookies; // final bill description output System.out.printf("%-15s x%-10d $%.2f ", "Bread" , noBread, totalBread); System.out.printf("%-15s x%-10d $%.2f ", "Chicken" , noChicken, totalChicken); System.out.printf("%-15s x%-10d $%.2f ", "Chips" , noChips, totalChips); System.out.printf("%-15s x%-10d $%.2f ", "Cookies" , noCookies, totalCookies);
// sub-total, as a sum of all the products subTotal = totalBread + totalChicken + totalChips + totalCookies; tax = (SALES_TAX * subTotal) / 100 ; grandTotal = subTotal + tax; System.out.printf(" "); System.out.printf(" "); System.out.printf("%-27s $%.2f ", "Sub Total : " , subTotal); System.out.printf("%-27s $%.2f ", "Tax : " , tax); System.out.printf(" "); System.out.printf("%-27s $%.2f ", "Total : " , grandTotal); System.out.printf(" -----------------------------------------------------------------------------------------------"); }
}
this code is in JAVA there are some errors that I cant find can u fix it including any typos
here's what the output should be like
SAMPLE INPUT/OUTPUT Welcome to the market! Please see our items below. Bread $1.40/ loaf Chicken $2.75/1b Chips $3.30/ bag Cookies $2.60/ box How many loafs of bread would you like? 2 How many pounds of chicken would you like? 10 How many bags of chips would you like? 3 How many boxes of cookies would you like? 1 Thank you for shopping with us! Please find your receipt below. SUBMISSION Please submit a file called Main.java to blackboard before the deadline
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started