Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here's an image attached on how the result should come out. and those greenish-blue (2,10,3,1) numbers are just how our compiler lets us write input

image text in transcribed

here's an image attached on how the result should come out.

and those greenish-blue (2,10,3,1) numbers are just how our compiler lets us write input in the result. So DON'T write a code to change color to greenish-blue

image text in transcribed

This is how far we've come in class( have attached some code from the class), So please write the code in java only. and Write it in a beginner-friendly way (it's a beginner class).

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);

}

}

Thank you

And please keep the code in a beginner's way(like how a beginner would write it). the class is supposed to be for beginners.

I submitted this before and the response was in an Advanced way. Please write code in a beginner's way (like how a beginner would write it)

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions