Answer both questions. You will be submitting 2 separate .java files to this assignment. Each solution is worth 15 points
Please make sure your code is follows the guidelines located inProgramming Style and StandardsandJavadoc Style Comments
This assignment must use the Scanner class for user input.Your solution to each problem must be your own. Please do not collaborate with each other and submit similar looking files.
- You are traveling to a vacation destination. Create a Java class that computes and displays the fuel efficiency of your vehicle represented as miles per gallon. Your class must prompt the user to input the following
Odometer reading at the beginning of journey (Odometer reading A)
Name of starting location
Odometer reading at the end of the journey (Odometer reading B)
Name of ending location
The amount of gasoline used in that time-period
The formula to calculate fuel efficiency is
Mpg = Odometer reading B - Odometer reading A
----------------------------------------
Gallons
Example execution:
Calculating Fuel Efficiency...
Odometer at start: 156000
Start Location: Washington DC
Odometer at end: 156492
End Location: Boston
Gasoline: 52
The output must be formatted as follows:
Odometer Reading
Washington DC 156000
Boston 156492
Gasoline used 52
Fuel efficiency 9.46 mpg
Hint: Use escape sequences where appropriate to format your output
- Create a Java class that asks for a person’s name and age in years, and his/her sibling’s name and age in years. You must then convert both ages into minutes and display the difference.
Example execution:
Calculating age difference in minutes...
Enter first name: Nina
Enter age: 24
Enter second name: Enrico
Enter age: 21
The output must be formatted as follows:
Name Age Age in Minutes
Nina 2412614400
Enrico 2111037600
The difference in age is 1576800
Hint: Use escape sequences where appropriate to format your output