Programming Challenge Chapter 3 – Q #8 How Much Insurance? – Tony Gaddis – Starting Out With C++
Problem: -
Many financial experts advise that property owners should insure their homes or buildings for at least 80 percent of the amount it would cost to replace the structure. Write a
program that asks the user to enter the replacement cost of a building and then displays
the minimum amount of insurance he or she should buy for the property.
Solution: -
#include <iostream>
using namespace std;
int main()
{
const float insurance_percentage = 0.8;
float cost;
float minimum_cost = 0.0;
cout << "Enter Minimum Cost:
";
cin >> cost;
minimum_cost = insurance_percentage * cost;
cout << "Your Minmum Cost
Of Replacing Strucher is " << minimum_cost;
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Input is highlighted with yellow color.
Explanation of this Solution
- Declare a float constant and initialize given values.
- Declare a float variable for input.
- Declare a float variable for per serving calculation.
- Take input from the user by using cin.
- Calculate the value of cost.
- In last, display output on the screen.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments