Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I would like help with this assignment... Now that you have created most of

ID: 663163 • Letter: H

Question

Hi, I would like help with this assignment...

Now that you have created most of the code as well as the front end features and buttons, create a calculator function to enable users to calculate their own costs if they choose. Be sure to follow the same format that you have been using for the previous assignments.

Goal

The goal of the project is for you to create a working java application that calculates various traveling elements (gas mileage, oil changes, and tank capacity) and applies the code and Java skills that you acquire throughout the course.

For this project you are developing an application called the Traveler's Gasoline Calculator (TGC), which (as the name states) calculates gasoline costs for the drivers of several different types of vehicles.

So far this is what I have: Can someone check my code and let me know if I did it right..

import java.util.Scanner;
public class tripCost
{
   public static void main(String[] args)
   {
       double totalCostOfTrip = 0;   

Scanner scan = new Scanner(System.in);

System.out.println("Please enter how much miles you want to travel?");
int totalMiles = scan.nextInt();

System.out.println("What is the cost of gasoline? Super Unleaded: $3, Unleaded: $2.90, Leaded: $2.50 and Diesel: $4.00");
double gasCost = scan.nextDouble();
  
System.out.println("Please enter MPG of car?");
int milesPerGallon = scan.nextInt();
  
System.out.println("For tip more than 300 miles, oil change is required. If oil change is required. Please enter Y or N");
char oilChangeCost = scan.next().charAt(0);
if (Character.toUpperCase(oilChangeCost) == 'Y'){
System.out.println("The cost to change oil is $30 and it will bge added to your travel cost");
totalCostOfTrip += 33.00;
}

double tripCost = (totalMiles / milesPerGallon * gasCost);
totalCostOfTrip += tripCost;

String choice = "1. Select 1 for trip cost calculationl "
+ "2. Select 2 to exit from system";

System.out.println(choice);
int ch = scan.nextInt();
if (ch == 1){
System.out.println(String.format("Your cost for the trip is $" + totalCostOfTrip + "."));
} else {
System.exit(0);
}

Explanation / Answer

this code is good..

u can also do the followings.To get more abstract.

Also create the following:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote