fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. using namespace std;
  5. int main()
  6. {
  7. float price; //the price of the vehicle purchased
  8. float downpayment; //the down payment on the loan
  9. float tradein; //the amount of the trade in
  10. float loanamt; //the amount of the loan
  11. float annualintrate; //annual interest rate
  12. float annualintpercent; //annual interest rate as a fraction
  13. float monintrate; //monthly interest rate as a percent
  14. int nomonths; //number of monthly payments
  15. float monpayment; //monthly payment amount
  16.  
  17. monintrate = annualintrate / 12;
  18. annualintpercent = annualintrate * 100;
  19. loanamt = price - downpayment - tradein;
  20. monpayment = (loanamt * monintrate) / (1.0 -(1 + monintrate) ^ -nomonths);
  21.  
  22. do //looping for the price to be between 50 and 50,000
  23. {
  24. cout << "please enter the price of the vehicle (between 50 and 50,000) :" << endl;
  25. cin >> price;
  26. } while (price < 50 || price > 50000);
  27.  
  28.  
  29. do //looping for the tradin value
  30. {
  31. cout << "please enter the amount for the trade in vehicle:" << endl;
  32. cin >> tradein;
  33. } while (tradein >= 0 ||tradein < price);
  34.  
  35. do //looping for the downpayment amount
  36. {
  37. cout << "please enter the amount for the downpayment where the downpayment is less than the price minus the trade in value" << endl;
  38. cin >> downpayment;
  39. } while (downpayment >= 0 ||downpayment > price - tradein);
  40.  
  41. do //looping for the annual interest rate
  42. {
  43. cout << "enter the annual interest rate for the loan as a decimal (ie .4 for 40%)" << endl;
  44. cin >> annualintrate;
  45. } while (annualintrate >= 0 ||annualintrate > 50);
  46.  
  47. //Giving Back the Info!
  48. cout << "Honest Dave's used cars" << endl;
  49. cout << endl;
  50. cout << "Vehicle price: " << price << endl;
  51. cout << "Trade in value: " << tradein << endl;
  52. cout << "Down Payment: " << downpayment << endl;
  53. cout << " ----------" << endl;
  54. cout << "Loan Amount: " << loanamt << endl;
  55. cout << "Annual Interest Rate: " << annualintpercent << "%" << endl;
  56. cout << endl;
  57. cout << "Monthly Payment Options" << endl;
  58. cout << endl;
  59. {
  60. nomonths = 24;
  61. cout << "24 months: " << monpayment << endl;
  62. }
  63. {
  64. nomonths = 36;
  65. cout << "36 months: " << monpayment << endl;
  66. }
  67. {
  68. nomonths = 48;
  69. cout << "48 months: " << monpayment << endl;
  70. }
  71. {
  72. nomonths = 60;
  73. cout << "60 months: " << monpayment << endl;
  74. }
  75.  
  76.  
  77. return 0; //DONE!
  78. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:20: error: invalid operands of types 'double' and 'int' to binary 'operator^'
stdout
Standard output is empty