Advertisement
Guest User

Classwork #1

a guest
Sep 16th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. int main()
  6. {
  7. int seconds, minutes;
  8. cin>>seconds;
  9. minutes = seconds / 60.0;
  10. cout<<"There are "<<setprecision(2)<<int(minutes)<<" minutes and "<<int(seconds%60)<<" seconds in "<<int(seconds)<<" seconds."<<endl;
  11.  
  12. int fahrenheit;
  13. cin>>fahrenheit;
  14. int celsius = (5.0 / 9) * (fahrenheit - 32);
  15. cout<<"There are "<<celsius<<" degrees Celsius in "<<fahrenheit<<" degrees Fahrenheit."<<endl;
  16.  
  17. double price, tax, total;
  18. cin>>price;
  19. tax = price * .06;
  20. total = price + tax;
  21. cout<<fixed<<"Your item costs "<<price<<" dollars, the tax is "<<tax<<" dollars, and the price after tax is "<<setprecision(2)<<total<<" dollars."<<endl;
  22.  
  23. double annualInterestRate, monthlyInterestRate, loanAmount, numberOfYears, monthlyPayment, totalPayment;
  24. cout<<"Please input your Annual Interest Rate in digits.\n";
  25. cin>>annualInterestRate;
  26. cout<<"Please input your number of years in digits.\n";
  27. cin>>numberOfYears;
  28. cout<<"Please input your Loan Amount in digits.\n";
  29. cin>>loanAmount;
  30. monthlyInterestRate = annualInterestRate / 1200;
  31. monthlyPayment = (loanAmount * monthlyInterestRate) / (1 - (1/pow((1+monthlyInterestRate),(numberOfYears*12))));
  32. totalPayment = monthlyPayment*(numberOfYears*12);
  33. cout<<fixed<<"Your Monthly Payment is "<<monthlyPayment<<" dollars and your Total Payment is "<<totalPayment<<" dollars."<<endl;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement