fork download
  1. /******************************************************************************
  2.  * AUTHOR : Aiden Stannard *
  3.  * STUDENT ID : 1284603 *
  4.  * Ch3, p146, #16: Interest Earned *
  5.  * CLASS : CS1A *
  6.  * SECTION : T/Th 6PM - 8:20PM *
  7.  * DUE DATE : 9/12/2026 *
  8.  ******************************************************************************/
  9. /******************************************************************************
  10.  * CALCULATE INTEREST EARNED
  11.  * ____________________________________________________________________________
  12.  * This program Calculates the amount of interest in dollars a user earned by
  13.  * prompting the user to enter the following info: Initial balance
  14.  * dollars(principal), Interest rate as decibal(rate), and the frequency the
  15.  * interest is compounded annually(T)
  16.  *
  17.  * Computation is based on the formula: (principal * pow((1+rate/T),T)) - principal
  18.  * ____________________________________________________________________________
  19.  * INPUT
  20.  * What was your initial balance?:__
  21.  * What is your interest rate as a decibal value?:__
  22.  * How many times is interest compounded per year?:__
  23.  *
  24.  *OUTPUT
  25.  * You've earned:__
  26.  *
  27.  ******************************************************************************/
  28. #include <iostream>
  29. #include <cmath>
  30. using namespace std;
  31.  
  32. int main()
  33. {
  34. float principal; // Initial balance of account
  35. float rate; // Interest Rate As a decibal value
  36. float T; // Number of times interest is compounded over a year period
  37. float amount; // Interest earned in dollars
  38.  
  39. cout << "What was your initial balance?: \n";
  40. cin >> principal;
  41. cout << "What is your interest rate as a decibal value?: \n";
  42. cin >> rate;
  43. cout << "How many times is interest compounded per year?: \n";
  44. cin >> T;
  45. amount = principal * pow((1+rate/T),T); // Calculates earning using inputs
  46. cout << "You've earned: " << amount - principal << " Dollars In interest" << endl;
  47. return 0;
  48. }
Success #stdin #stdout 0s 5320KB
stdin
100
.1
1
stdout
What was your initial balance?: 
What is your interest rate as a decibal value?: 
How many times is interest compounded per year?: 
You've earned: 10 Dollars In interest