fork download
  1. //Maxwell Brewer CS1A Chapter 3, P. 143, #8
  2. //
  3. /***************************************************************
  4.  *
  5.  * CALCULATE INSURANCE COST
  6.  * _____________________________________________________________
  7.  *
  8.  * This program will calculate the cost of homeowners insurance
  9.  * based off the user input of the price of their home.
  10.  * _____________________________________________
  11.  * INPUT
  12.  *
  13.  * Cost to build
  14.  *
  15.  * OUTPUT
  16.  *
  17.  * Minimum cost of insurance
  18.  *
  19.  ***************************************************************/
  20.  
  21. #include <iostream>
  22. #include <iomanip>
  23. #include <string>
  24.  
  25. using namespace std;
  26.  
  27. int main() {
  28.  
  29. // Initialization
  30.  
  31. const char msgBuildCost[50] = "\n Enter replacement cost of the building: ";
  32. const char msgInsureCost[40] = "\n The minimum amount of insurance is ";
  33.  
  34. double buildCost, minPrice;
  35.  
  36. // Display input prompts
  37.  
  38. cout << msgBuildCost;
  39. cin >> buildCost;
  40.  
  41. minPrice = (buildCost*0.8); //calculate minimum insurance cost
  42.  
  43. // Output
  44.  
  45. cout << msgInsureCost;
  46. cout << minPrice;
  47.  
  48. return 0;
  49. }
Success #stdin #stdout 0s 5284KB
stdin
1000
stdout
 Enter replacement cost of the building: 
 The minimum amount of insurance is 800