
A liter is 0.264179 gallons. Write a

List of variables:
number_of_miles: Store the number of miles travelled.
liter_of_gas: Store the quantity of gasoline consumed.
List of functions used:
cout.setf(ios::showpoint): For controlling the floating and trailing zeros.
cout.precision(2): Dislay the values up to two digits.
cin(): To take input from input streams like keyboard, files etc.
cout(): To display the output.
Summary Introduction:
Program will use the Main () method to prompt the user to enter the number of miles traveled and the number of gasoline consumed to find the number of miles per gallon car delivered. A liter is equal to 0.264179 gallons.
Program Description:
The purpose of the program is to find the number of miles per gallon car delivered.
Explanation of Solution
Program:
Following is the C++ program to find the number of miles per gallon car delivered.
/*
* Program: The program asks user to provide the number of miles car travelled and the amount of gasoline consumed to find the number of miles per gallon car delivered.
*/
#include <iostream> Usingnamespacestd; constdouble LITRE =0.264179; // A liter is equal to 0.264179 gallons doublemiles_per_gallons(float,float); intmain(){ cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); charans; do{ // declare the variables. Floatnumber_of_miles,liter_of_gas; cout<<"Enter the number of miles traveled: "; cin>>number_of_miles; cout<<"\nEnter the number of liters of gasoline consumed: "; cin>>liter_of_gas; cout<<endl<<miles_per_gallons(number_of_miles,liter_of_gas); cout<<endl<<"Do you want to calculate again? "; cin>>ans; }while(ans=='Y'||ans=='y'); cout<<"\nThank You!"; return0; } // function to calculate the miles per gallon car delivered. doublemiles_per_gallons(floatnumber_of_miles,floatliter_of_gasoline){ returnnumber_of_miles/(liter_of_gasoline*LITRE); }
Explanation:
The above program prompts the user to enter the number of miles traveled and the number of gasoline consumed and after that function miles_per_gallons() is defined to find the number of miles traveled by gasoline consumed in liter. Then cout() function is used to show the output of the program.
Sample Output:
Following is the sample output for the given program:
Enter the number of coupons: 25 The number of Candy bars: 2 The number of Gum Balls: 1 The remaining coupons are: 2
Want to see more full solutions like this?
Chapter 3 Solutions
Absolute C++
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Starting Out with C++: Early Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Management Information Systems: Managing The Digital Firm (16th Edition)
Starting Out With Visual Basic (8th Edition)
Concepts Of Programming Languages
- Information Security Risk and Vulnerability Assessment 1- Which TCP/IP protocol is used to convert the IP address to the Mac address? Explain 2-What popular switch feature allows you to create communication boundaries between systems connected to the switch3- what types of vulnerability directly related to the programmer of the software?4- Who ensures the entity implements appropriate security controls to protect an asset? Please do not use AI and add refrencearrow_forwardFind the voltage V0 across the 4K resistor using the mesh method or nodal analysis. Note: I have already simulated it and the value it should give is -1.714Varrow_forwardResolver por superposicionarrow_forward
- Describe three (3) Multiplexing techniques common for fiber optic linksarrow_forwardCould you help me to know features of the following concepts: - commercial CA - memory integrity - WMI filterarrow_forwardBriefly describe the issues involved in using ATM technology in Local Area Networksarrow_forward
- For this question you will perform two levels of quicksort on an array containing these numbers: 59 41 61 73 43 57 50 13 96 88 42 77 27 95 32 89 In the first blank, enter the array contents after the top level partition. In the second blank, enter the array contents after one more partition of the left-hand subarray resulting from the first partition. In the third blank, enter the array contents after one more partition of the right-hand subarray resulting from the first partition. Print the numbers with a single space between them. Use the algorithm we covered in class, in which the first element of the subarray is the partition value. Question 1 options: Blank # 1 Blank # 2 Blank # 3arrow_forward1. Transform the E-R diagram into a set of relations. Country_of Agent ID Agent H Holds Is_Reponsible_for Consignment Number $ Value May Contain Consignment Transports Container Destination Ф R Goes Off Container Number Size Vessel Voyage Registry Vessel ID Voyage_ID Tonnagearrow_forwardI want to solve 13.2 using matlab please helparrow_forward
- a) Show a possible trace of the OSPF algorithm for computing the routing table in Router 2 forthis network.b) Show the messages used by RIP to compute routing tables.arrow_forwardusing r language to answer question 4 Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.arrow_forwardusing r language to answer question 4. Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,


