Question: Write a C++ program that reads two decimal values from the user, one for the voltage V and the other for the resistance R. Then,

Write a C++ program that reads two decimal values from the user, one for the voltage V and the other for the resistance R. Then, the program should compute and output the power consumed by the resistance R (should use decimal devision) according to the following formula:

Your output (power consumption) should be displayed in a fixed decimal format with only two digits after the decimal point. Reading input from user should occur through a dedicated function. Computation of the power consumption should occur in another function. Printing the output to user should also occur in a third function.

NOTE: The code MUST compile in order to be considered for grading, otherwise it will receive an automatic ZERO. Also, if you solve the problem without using functions as required by the question, this is worth ONLY 1 mark out of the total marks.

Reading voltage and resistance from user is worth of 1 mark if working properly, otherwise it will receive a ZERO. Computing power consumption correctly is worth 2 marks (only if it works, otherwise ZERO). Formatting the output as required is worth 1 mark (only if it works, otherwise ZERO).

Attach File

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!