subject

Driving costs (with pointers)
Complete the program below using pointers.

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 by executing
cout << fixed << setprecision(2); once before all other cout statements. This line is included for you.

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.

#include
#include
using namespace std;

int main() {

/* Update the declarations below so that each variable points to a
* double on the heap.
*/

double *milesPerGallon;
double *dollarsPerGallon;
double *dollars20Miles;
double *dollars75Miles;
double *dollars500Miles;

/* Write the statements here to:
* 1) Read a value from the keyboard into the variable pointed to by
* milesPerGallon.
* 2) Read a value from the keyboard into the variable pointed to by
* dollarsPerGallon.
*/

/* Write the appropriate statements here to:
* 1) Assign the proper calculated value to the variable pointed to by
* dollars20Miles.
* 2) Assign the proper calculated value to the variable pointed to by
* dollars75Miles.
* 3) Assign the proper calculated value to the variable pointed to by
* dollars500Miles.
*/

cout << fixed << setprecision(2);

cout << *dollars20Miles << " " << *dollars75Miles << " " << *dollars500Miles << endl;

return 0;
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
You are almost finished updating a web site. as part of the update, you have converted all pages from html 4.0 to html5. the project is currently on schedule. however, your project manager has been asked by the marketing team manager to justify a day of time spent validating the site's html5 pages. the marketing team manager does not have technical knowledge of the internet or the web. which is the most appropriate explanation to provide to the marketing team manager?
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
question
Computers and Technology, 24.06.2019 14:00
Fast answer i need for apex ! smartphones should be banned from the classroom in public schools so that students cannot cheat on test so easily? which is an example of a counter argument to the thesis above? a.the classroom is a place for learning not for making phone calls b. smartphones are useful learning tools in the modern classroom c.banning smartphones will not students pay attention to teachers any better d. banning smartphones would decreased incidents of theft
Answers: 2
question
Computers and Technology, 24.06.2019 17:00
Following are uses of spreadsheets. for each use, choose whether the use is a business use, consumer use, or student use. family budget: sales data: recording research data for science class:
Answers: 2
You know the right answer?
Driving costs (with pointers)
Complete the program below using pointers.

Driving i...
Questions
question
Spanish, 07.07.2019 08:10
question
Biology, 07.07.2019 08:10
Questions on the website: 13722360