Programming Challenge Chapter 3 – Q #8 How Much Insurance? – Tony Gaddis – Starting Out With C++

Programming Challenge Chapter 3 – Q #8 How Much Insurance? – Tony Gaddis – Starting Out With C++







How Much Insurance

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

  1. Declare a float constant and initialize given values.
  2. Declare a float variable for input.
  3. Declare a float variable for per serving calculation.
  4. Take input from the user by using cin.
  5. Calculate the value of cost.
  6.  In last, display output on the screen.
  7. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File




Thanks! 



Post a Comment

0 Comments