Write a program that calculates a car's gas mileage. The program should ask the user to enter the number of gallons of gas the car can hold and the number of miles it can be driven on a full tank. It should then display the number of miles than may be driven per gallon of gas.
Write a program that calculates a car's gas mileage. The program should ask the user to enter the number of gallons of gas the car can hold and the number of miles it can be driven on a full tank. It should then display the number of miles than may be driven per gallon of gas.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
100%
Please solve it wothout using boolane and loop, solve it at entry level of programming c++. Thank you
![5.
using complete explanations (ex. "The square of 4 is 16", or "The tangent of
45 degrees is 1")
Solve the Programming Challenge 1, "Miles per Gallon", page 146 (144)
Write a program that calculates a car's gas mileage. The program should ask
the user to enter the number of gallons of gas the car can hold and the number
of miles it can be driven on a full tank. It should then display the number of
miles than may be driven per gallon of gas.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F44fc33fa-f0a7-4f0d-8fd2-501707f936b1%2F349a3f6d-d38c-4ce8-a334-854a4d513c9c%2Fqbh3paa_processed.jpeg&w=3840&q=75)
Transcribed Image Text:5.
using complete explanations (ex. "The square of 4 is 16", or "The tangent of
45 degrees is 1")
Solve the Programming Challenge 1, "Miles per Gallon", page 146 (144)
Write a program that calculates a car's gas mileage. The program should ask
the user to enter the number of gallons of gas the car can hold and the number
of miles it can be driven on a full tank. It should then display the number of
miles than may be driven per gallon of gas.
![144
Chapter 3 Expressions and Interactivity
Program 3-13
1 // This program displays three rows of numbers.
2 #include <iostream>
3 #include <iomanip>
using namespace std;
4
5
6
7
8
9
10
11
12
13
14
15
16
int main()
{
17
18
19
20
21
22
23
24 }
int num1 = 2897,
num4 = 34,
num7 = 390,
// Required for setw
num2 = 5,
num5 = 7,
num8 3456,
// Display the first row of numbers
cout<<setw(6) << num1 <<setw(6)
<< num2 <<setw(6) << num3 << endl;
num3 = 837,
num6 1623,
num9 = 12;
// Display the second row of numbers
cout<<setw(6) << num4 <<setw(6)
Program Output
2897
34
390 3456
<< num5 <<setw(6) << num6 << endl;
5 837
7 1623
12
// Display the third row of numbers
cout<<setw(6) << num7 <<setw(6)
<< num8 <<setw(6) << num9 << endl;
return 0;
By printing each number in a field of 6 positions, they are displayed in perfect columns.
NOTE: A new header file, <iomanip>, is included in Program 3-13. It must be used
in any program that uses setw.
Notice how a setw manipulator is used with each value, because setw only establishes a
field width for the value immediately following it. After that value is printed, cout goes
back to its default method of printing.
You might wonder what will happen if the number is too large to fit in the field, as in the
following statement:
value = 18397;
cout<<setw(2) << value;
In cases like this, cout will print the entire number. setw only specifies the minimum num-
ber of positions in the print field. Any number larger than the minimum will cause cout to
override the setw value.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F44fc33fa-f0a7-4f0d-8fd2-501707f936b1%2F349a3f6d-d38c-4ce8-a334-854a4d513c9c%2Ftkp3mn_processed.jpeg&w=3840&q=75)
Transcribed Image Text:144
Chapter 3 Expressions and Interactivity
Program 3-13
1 // This program displays three rows of numbers.
2 #include <iostream>
3 #include <iomanip>
using namespace std;
4
5
6
7
8
9
10
11
12
13
14
15
16
int main()
{
17
18
19
20
21
22
23
24 }
int num1 = 2897,
num4 = 34,
num7 = 390,
// Required for setw
num2 = 5,
num5 = 7,
num8 3456,
// Display the first row of numbers
cout<<setw(6) << num1 <<setw(6)
<< num2 <<setw(6) << num3 << endl;
num3 = 837,
num6 1623,
num9 = 12;
// Display the second row of numbers
cout<<setw(6) << num4 <<setw(6)
Program Output
2897
34
390 3456
<< num5 <<setw(6) << num6 << endl;
5 837
7 1623
12
// Display the third row of numbers
cout<<setw(6) << num7 <<setw(6)
<< num8 <<setw(6) << num9 << endl;
return 0;
By printing each number in a field of 6 positions, they are displayed in perfect columns.
NOTE: A new header file, <iomanip>, is included in Program 3-13. It must be used
in any program that uses setw.
Notice how a setw manipulator is used with each value, because setw only establishes a
field width for the value immediately following it. After that value is printed, cout goes
back to its default method of printing.
You might wonder what will happen if the number is too large to fit in the field, as in the
following statement:
value = 18397;
cout<<setw(2) << value;
In cases like this, cout will print the entire number. setw only specifies the minimum num-
ber of positions in the print field. Any number larger than the minimum will cause cout to
override the setw value.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY