Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I JUST WANT TO ANSWER THIS QUESTION : Task #5 - Create a program from scratch. In this task the student will create a new
I JUST WANT TO ANSWER THIS QUESTION :
Task #5 - Create a program from scratch. In this task the student will create a new program that calculates gas mileage in miles per gallon. The student will use string expressions, assignment statements, input and output statements to communicate with the user. 1. Create a new file in your IDE or text editor. 2. Create the shell for your first program by entering: public class Mileage { public static void main(String[] args) { // Add your declaration and code here. } } 3. Save the file as Mileage.java. 4. Translate the algorithm below into Java code. Don't forget to declare variables before they are used. Each variable must be one word only (no spaces). Print a line indicating this program will calculate mileage Print prompt to user asking for miles driven Read in miles driven Print prompt to user asking for gallons used Read in gallons used Calculate miles per gallon by dividing miles driven by gallons used Print miles per gallon along with appropriate labels 5. Compile the program and debug, repeating until it compiles successfully. 6. Run the program and test it using the following sets of data and record the results: Miles driven Gallons used Miles per gallon (hand calculated) Miles per gallon (resulting output) 2000 100 500 25.5 241.5 10 100 0 Miles driven Gallons used Miles per gallon (hand calculated) Miles per gallon (resulting output) 2000 100 500 25.5 241.5 10 100 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started