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 13:30
1. technician a says horsepower information can be used by consumers to compare the power of different automobile engines. technician b says that manufacturers will often list the horsepower output of their engines in the online service information. who is right?
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
What are some ways to use a range name in a formula? check all that apply. in the defined names group, click use in formula, and then select the desired name. begin typing the name in the formula, select a name from the autocomplete list, and use the arrow keys and tab key to enter the name in the formula. begin typing the formula, and then click and drag with the mouse to select the cells to include in the formula. right-click one of the cells in the range. click formula options, and use the dialog box to add the name.
Answers: 1
question
Computers and Technology, 23.06.2019 03:50
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria.what am i?
Answers: 2
question
Computers and Technology, 23.06.2019 15:20
An ou structure in your domain has one ou per department, and all the computer and user accounts are in their respective ous. you have configured several gpos defining computer and user policies and linked the gpos to the domain. a group of managers in the marketing department need different policies that differ from those of the rest of the marketing department users and computers, but you don't want to change the top-level ou structure. which of the following gpo processing features are you most likely to use? a, block inheritance b, gpo enforcement c, wmi filtering d, loopback processing
Answers: 3
You know the right answer?
Driving costs (with pointers)
Complete the program below using pointers.

Driving i...
Questions
Questions on the website: 13722362