Question: 1 f needed, install Java and then Eclipse on your machine. See instructions for this in the Course Software page from the Course Resources module

1 f needed, install Java and then Eclipse on your machine. See instructions for this in the Course Software page from the Course Resources module in Canvas. 2. Make a CS1410-Assignments Java project (File->New-> Java Project) 3. In your CS1410-Assignments project, make a package called a1 (File->New->Package or right-click on the project name in explorer). A package is basically a folder to organize code. 4. Create a new class called DrivingCostCalculator(File->New>Class or right-click on the a1 package name in the Eclipse package explorer). Check the box to automatically make a main method. Warning, in CS1410, using different package names or class names than specified will result in a loss of points. This includes capitalization and typing errors. 5. In your main method, declare and initialize variables of type double to store various quantities needed for the computation. The variables should be carefully named and use "lower camel case" style a. The quantities needed are 1. The driving distance, in miles 2. The gas vehicle's miles per gallon efficiency (a reasonable example value is 28.0) 3. The cost of gas in dollars per gallon (a reasonable example value is 2.75) 4. The electric vehicle's miles per kilowatt hour efficiency (a reasonable example value is 4.0) 5. The cost of electricity in dollars per kilowatt hour (a reasonable example Utah value is 0.106, or 10.6 cents per kWh) 6. Write a static method that computes and returns the cost of the trip for a gas vehicle given the length of the trip, the miles per gallon efficiency, and the cost of gas in dollars per gallon. Write this method above the main method and inside the class body. The start of the method should be exactly: public static double calculateGasTripCost(double milesToDrive, double milesPerGallon, double dollarsPerGallon) Add code to this method to compute the cost of the trip. The cost of the trip is the distance dollars per gallon miles per gallon. This is easier to understand if it is broken into two parts: 1. The number of gallons used is the miles/ miles per gallon 2. The cost of the trip is the number of gallons dollars per gallon 3. Using these two formulas, calculate the cost of the trip in two stages. First calculate the number of gallons used and store the result in a clearly named variable. Secondly, use that variable and the dollars per gallon to compute a final cost. Store this final cost in a usefully-named variable 4. Return this final cost from the function. Do not produce text output in the function. Note that this assignment specification asks not only a certain result, but also a specific way of solving the problem. Follow this step-by-step specification. 7. Write a static method that computes and returns the cost of the trip for an electic vehicle given the length of the trip, the miles per kilowatt-hour efficiency, and the cost of electricty in dollars per kilowatt-hour. Write this method above the main method and inside the class body. The start of the method should be exactly: public static double calculateElectricTripCost double milesToDrive, double milesPerKWh, double dollarsPerKWh) Similar to the computation for the gas car, write code in this method to first calculate how many kilowatt-hours of electricity is needed for the trip and then calculate a cost by multiplying the kilowatt-hours with the cost per kilowatt-hour. Return that cost from the method. 8. Back in the main method, call the calculateGasTripCost method and the calculateElectricTripCost with the values stored in the variables. Store the computed trip costs in appropriately-named variables. be in the body of a public static void method that looks like public static void displayBanner) As an example, the banner should display something (but not exactly) like: 9. In order to improve the marketability of this program, make a method that displays a text banner. The code for the text banner should Driving Cost Calculator You may use your creativity for what is displayed. This method should not return anything, just produce output when called. 10. Finish the program in main by first calling the displayBanner method and then displaying the cost of the trips and explanatory text to the console (using System.out.println). The output must look like the following example, except the number result can change. The cost of a 100.0 mile trip by gas is $9.82 and by electric is $2.65. You must format the trip cost to have only two digits (for pennies) using the String.format method. If number is a double, the assignment String formattedNumber-String, format("%.2f", number); will store into formattedNumber the result of formatting number into a string containing two decimal places. You can output that formatted number instead of the double variable that holds the cost
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
