Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     // Define Year Vars.
  8.     int StartYear, EndYear;
  9.     // Define Inflation & Amount Vars.
  10.     float TotalInflation, AverageYearlyInflation, StartAmount, EndAmount;
  11.    
  12.     // Prompt for and get Start (index) Year.
  13.     cout << "Enter the starting year (Index Year): ";
  14.     cin >> StartYear;
  15.    
  16.     //Prompt for and get Start (index) Amount.
  17.     cout << "\nEnter the starting amount (Index Amount): ";
  18.     cin >> StartAmount;
  19.    
  20.     //Prompt for and get Ending Year.
  21.     cout << "\nEnter the ending year: ";
  22.     cin >> EndYear;
  23.    
  24.     //Prompt for and get Ending Amount.
  25.     cout << "\nEnter the ending amount: ";
  26.     cin >> EndAmount;
  27.  
  28.     //Calculate Total Percentage Difference between End Amount and Start Amount.
  29.     TotalInflation = EndAmount/StartAmount;
  30.     //DEBUG: Prints out TotalInflation for Verification
  31.     //cout << "\n\nTotal Inflation: " << (TotalInflation*10) << "%\n"; system("pause");
  32.  
  33.     //Calculate Average Inflation Amount per Year (TotalInflation/Difference of End & Start Years)
  34.     AverageYearlyInflation = 1+(TotalInflation/(EndYear-StartYear));
  35.     //DEBUG: Prints out AverageYearlyInflation for Verification, Pause After Displaying.
  36.     //cout << "\nAverage Yearly Inflation: " << (AverageYearlyInflation*10) << "%\n"; system("pause");
  37.  
  38.     //Display Total Inflation, output in user-friendly readable %ile format.
  39.     cout << "\nTotal Inflation: " << (TotalInflation*10) << "%\t\t";
  40.     cout << "Average Rate of Inflation: " << (AverageYearlyInflation*10) << "% per year\n"; system("pause");
  41.  
  42.     //End main, return 0.
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement