Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here's the code I have written so far, can u fix it so it displays the requirement according to the question (For the requirement see

image text in transcribed

Here's the code I have written so far, can u fix it so it displays the requirement according to the question (For the requirement see the image attached below, the image above is the question)

// Import the Scanner class to read input from the user

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

double bread, chicken, chips, cookies, subtotal, tax, total;

// Define constant prices for each item

final double BREAD_PRICE = 1.40, CHICKEN_PRICE = 2.75, CHIPS_PRICE = 3.30, COOKIES_PRICE = 2.60, TAX_RATE = 0.06;

// Greet the user and display the available items and their prices

System.out.println("Welcome to the Market!");

System.out.println("The items available for purchase are:");

System.out.println("1) Bread - $" + BREAD_PRICE + "/loaf");

System.out.println("2) Chicken - $" + CHICKEN_PRICE + "/lb");

System.out.println("3) Chips - $" + CHIPS_PRICE + "/bag");

System.out.println("4) Cookies - $" + COOKIES_PRICE + "/box");

// Prompt the user to enter the quantity of each item they would like to purchase

System.out.print(" Enter the number of loaves of bread you would like to purchase: ");

bread = sc.nextDouble() * BREAD_PRICE;

System.out.print("Enter the number of pounds of chicken you would like to purchase: ");

chicken = sc.nextDouble() * CHICKEN_PRICE;

System.out.print("Enter the number of bags of chips you would like to purchase: ");

chips = sc.nextDouble() * CHIPS_PRICE;

System.out.print("Enter the number of boxes of cookies you would like to purchase: ");

cookies = sc.nextDouble() * COOKIES_PRICE;

// Calculate the subtotal, tax, and total

subtotal = bread + chicken + chips + cookies;

tax = subtotal * TAX_RATE;

total = subtotal + tax;

// Display the receipt

System.out.println(" Receipt:");

System.out.println("Bread: $" + bread);

System.out.println("Chicken: $" + chicken);

System.out.println("Chips: $" + chips);

System.out.println("Cookies: $" + cookies);

System.out.println("Subtotal: $" + subtotal);

System.out.println("Tax: $" + tax);

System.out.println("Total: $" + total);

}

}

image text in transcribed

PURPOSE This assignment will test your ability to write a basic computer program in Java. By the end of this assignment, you should feel comfortable utilizing basic input/output, variables, arithmetic expressions, and other basic concepts we have gone over in class. PROBLEM Create a program that allows the user to select a specific quantity of items from a market. The market has 4 items: 1) Bread - $1.40/ loaf 2) Chicken - $2.75/lb 3) Chips - $3.30/ bag 4) Cookies - $2.60/ box Start by greeting the user and displaying the items of the market. Then, prompt the user to enter the quantity of each item. Then, calculate the total of each item purchased, the subtotal, the tax, and the final price. Assume there is a standard sales tax rate of 6%. Display these results as a formatted receipt to the console. RUBRIC 15 points - Your program can produce the EXACT output seen in the sample input/output 15 points - Your program adheres to the best practices discussed in class. 10 points - Your program compiles and runs without any errors. 10 points - Your code is well documented with comments. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

What are the three standard parts of an EDI data transmission?

Answered: 1 week ago

Question

What are some of the possible scenes from our future?

Answered: 1 week ago