So in the beginning, Im sure i can ditch #include <string>...
Im sure at the end, where i have a million cout's (42-69) that could be simplified (i feel like the inverse of the distributive property in math could be applied.
I want the ouput to look the same. this seems to work for me for numbers 99,999.00 and smaller. If there is an approach that will allign all dollar signs, (and all decimal points) while keeping the percentages and integers and ends (.00) of the setprecision(2) numbers justified right.
This is in my 4th class and my proffessor is such a useless D-bag. one class he decided to read his powerpoints out loud (loudly to himself) without displaying them. I learn absoloutely nothing in class and I only have the book, (sample programs) and google to help me with the rest.
thanks
I might be confusing so let me know if i can clarify...
Again, i got it to output the way i want to, I just feel like i did it in a complicated manner. (i moved all the bricks from one side to another alright, but i did it one mollecule at a time instead of with a forklift... if you catch my analogy.)
//This program is used to calculate: Monthly Payment, Amount Paid Back, and Interest Paid
//from the inputs: Loan Amount, Monthly Interest Rate, and Number of Payments.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
float L ;
float RatePercent ;
float N ;
float monthlyPayment=0 ;
float amountPaid ;
float interestPaid ;
float Rate ;
cout << setprecision(2) <<fixed << showpoint <<setw(10);
//Prompt user to enter data
cout << "Enter the following amounts: \n" ;
cout << "Loan Amount: " ;
cin >> L ;
cout << "Yearly Interest Rate: ";
cin >> RatePercent ;
cout << "Number of Payments: ";
cin >> N ;
//Calculate Monthly Payment, Amount Paid Back, and Interest Paid.
Rate = RatePercent / 1200 ;
monthlyPayment = L * (Rate * pow((1+Rate),N))/((pow((1+Rate),N)-1));
amountPaid = monthlyPayment * N;
interestPaid = amountPaid - L;
//Display calculated data
cout << endl << endl << endl;
cout << "Loan Amount: " ;
cout << setw(12) ;
cout << "$ " ;
cout << setw(8);
cout << L << endl ;
cout << "monthly Interest Rate: " ;
cout << setw(9);
cout << setprecision(0) << noshowpoint ;
cout << RatePercent/12 << "%\n" ;
cout << "Number of Payments: " ;
cout << setw(13);
cout << N << endl ;
cout << showpoint << setprecision(2) ;
cout << "Monthly Payment: " ;
cout << setw(8);
cout << "$ " ;
cout << setw(8);
cout << monthlyPayment << endl;
cout << "Amount Paid Back: " ;
cout << setw(7) ;
cout << "$ " ;
cout << setw(8);
cout << amountPaid << endl;
cout << "Interest Paid: " ;
cout << setw(10);
cout << "$ ";
cout << setw(8);
cout << interestPaid << endl;
system("pause");
return 0;
}