Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: yourValue); System.out.printf("%.2f",

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter4: Making Decisions
Section: Chapter Questions
Problem 7E: Write a program named GuessingGame that generates a random number between 1 and 10. (In other words,...
icon
Related questions
Question

Java. Output driving costs.

77
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for
20 miles, 75 miles, and 500 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf("%.2f", yourValue);
The output ends with a newline.
Ex: If the input is:
20.0 3.1599
the output is:
3.16 11.85 79.00
Note: Real per-mile cost would also include maintenance and depreciation.
407614 241 336.qx3zqyT
LAB
0/10
2.20.1: LAB: Driving costs
ACTIVITY
LabProgram.java
Load default template..
1 import java.util.Scanner:
80°F
4
O
Type here to search
21
H
Transcribed Image Text:77 Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue); The output ends with a newline. Ex: If the input is: 20.0 3.1599 the output is: 3.16 11.85 79.00 Note: Real per-mile cost would also include maintenance and depreciation. 407614 241 336.qx3zqyT LAB 0/10 2.20.1: LAB: Driving costs ACTIVITY LabProgram.java Load default template.. 1 import java.util.Scanner: 80°F 4 O Type here to search 21 H
LAB
ACTIVITY
1 import java.util.Scanner;
2
3 public class LabProgram {
5
2.20.1: LAB: Driving costs
6
71
public static void main(String[] args) {
/* Type your code here. */
}
8
Develop mode Submit mode
CA
LabProgram.java
Load defau
Run your program as often as you'd like, before submitting for grading. Below, type any
input values in the first box, then click Run program and observe the program's output in
second box.
Ei
80°F
10 c
NO
Entor program innut (ontionall
Type here to search
Transcribed Image Text:LAB ACTIVITY 1 import java.util.Scanner; 2 3 public class LabProgram { 5 2.20.1: LAB: Driving costs 6 71 public static void main(String[] args) { /* Type your code here. */ } 8 Develop mode Submit mode CA LabProgram.java Load defau Run your program as often as you'd like, before submitting for grading. Below, type any input values in the first box, then click Run program and observe the program's output in second box. Ei 80°F 10 c NO Entor program innut (ontionall Type here to search
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,