Question: This is the question. Please write in JAVA. This is for a beginners' class so, please write it in a way a beginner would write

This is the question. Please write in JAVA. This is for a beginners' class so, please write it in a way a beginner would write with basic concepts.
I have attached a picture of what the output is supposed to be.
Here is also how far we've come in class, so please keep it within the same level
import java.util.Scanner;
public class Main {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String name, location; double distanceKm, distanceMi, mph, mpg, gasPrice, totalPrice, gallonsUsed, hours; final double MILES_IN_A_KM = 0.621371; // greet the user and prompt them for their name System.out.print("What is your name? "); name = sc.next(); System.out.println(" Hello " + name + ". Welcome to the trip calculator! "); // obtain the location, distance, mph, mpg, and cost of gas from the user System.out.print("Location: "); location = sc.next(); System.out.print("Distance (km): "); distanceKm = sc.nextDouble();
System.out.print("Vehicle Speed (mph): "); mph = sc.nextDouble();
System.out.print("Vehicle mpg: "); mpg = sc.nextDouble();
System.out.print("Cost of Gas per Gallon: "); gasPrice = sc.nextDouble(); System.out.println(" ---------------------------------------- "); System.out.println("Below are the results for your trip to " + location); // convert the distance in km to miles distanceMi = distanceKm * MILES_IN_A_KM; // calculate how many gallons of gas were used gallonsUsed = distanceMi / mpg; // calcaulte how many hours the trip will take hours = distanceMi / mph; // calculate the total price of the trip totalPrice = gasPrice * gallonsUsed; // output the gallons used, hours, and trip cost System.out.printf("%-15s %.1f gals ", "Gallons used: ", gallonsUsed); System.out.printf("%-15s %.1f hrs ", "Hours driven: ", hours); System.out.printf("%-15s $%.2f ", "Trip cost: ", totalPrice);
Please keep the code in beginners way
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
Get step-by-step solutions from verified subject matter experts
