ISOM3029 Assi1
ISOM3029 Assi1
Evaluation Table
Program:
// Program description:
//1.The program solved: Reverse a positive three-digit integer number.
//2.Limitation: It makes the program a little bit long. because before it comes to the
while loop, it reverse the number for one time.
//And if I enter a character instead of three-digit integer number, it will run without
stopping.
#include <iostream>
cin >> A;
//While the user input Y, calculate the reverse number
while (A == 'Y')
{
cout<< "+++++++++++++++++++++++++++++++++++++++++++
+++++++++\n"<<" \n";
cout << "Please enter a positive three-digit number:" ;
int number;
cin >> number;
}
//If user input N, end the program
if (A == 'N')
{
cout << "+++++++++++++++++++++++++++++++++++++++++++
+++++++++\n" << " \n";
cout << "Thank you very much!";
}
Suggestion:
1. It is hard for me to do the reverse number in a short time, and I have to search on the Internet
to know about some other information.
2. I used the A=’Y’ as a condition of continue the reverse program. But it failed. And then I
found that I should use the A= =’Y’, because Y is a character and “=”is used not as a equal
sign in C++.
3. I learnt the row in the sample output comes from the add signs“ +”
4. I learnt how to calculate the reverse number of a three-digit number.
5. I learnt how to use the while loop to make the program continue again.
6. I don’t want this question in my exam because the time of the exam is limited. But this
assignment takes me a long time to finish.
7. I learnt how to use “\n” to start a new line and make the output of program clearly.
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
int loan;
double rate;
int payment;
int months;
double fvalue;
double interest;
double repaid;
//Welcome the user to the Personal Loan System
cout << "Welcome to the Personal Loan System\n" ;
cout << "===================================\n";
//Prompt the user to enter the loan amount
cout << "\nPlease enter the loan amount : ";
cin >> loan;
//Prompt the user to enter the annual interest rate
cout << "Please enter the annual interest rate(%) : " ;
cin >> rate;
//Prompt the user to enter the monthly payment
cout << "Please enter the monthy payment : " ;
cin >> payment;
//Error-checking:If user input any negative number of loan,rate or payment,
display error
if (loan < 0 || rate < 0 || payment < 0)
cout << "\nError! You should input non-negative number of loan,rate and
payment!" << endl;
else
{
//Print the table body
cout <<"\n" << setw(5) << "Month" << setw(26) << "Current face
value" << setw(12) << "Interest" << setw(20) << "Repaid Principal" << endl;
cout <<
"===================================================
===========\n";
//Calculate the month, current face value, interest and repaid principal
months = 1;
fvalue = loan;
interest = fvalue * rate / 1200;
repaid = payment - interest;
}
//Display the result
cout << "Remaining Balance in month " << months << "= " << "$" <<
fvalue << endl;
cout << "(Note: The remaining balance " << "$" << fvalue << " will be
settled in the last month!)" << endl;
}
return 0;
}
Suggestion:
1. It is hard for me to work out the interest and repaid formula in a short time, and I have to
search on the Internet to know about some other information.
2. I initially set the limitation of while is” face value>0”, but it always output the result of the
face value of month 121. It takes me a long time to think about this and I finally found I
should change the limitation into “face value>monthly payment”.
3. In the beginning, I use the “static_cast” to make the result in a two decimal number, but it
shows if the result is an integer, it will not display “.00”, so I change it to the
“setprecision(2)” to keep the decimal number 0.
4. I learnt how to make a table which looks similar to the requirement of assignment by using
“setw()”.
5. I learnt the row in the sample output comes from the add signs“ +”
6. I learnt how to use the “||” to show the meaning of “or” in “if condition”.
7. I don’t want this question in my exam because the time of the exam is limited. But this
assignment takes me a long time to finish.
8. Application: I think this program can also be used by the students and teachers of GEST1001,
because the content of loan and interest is a part of this course.
9. I learnt how to use “\n” to start a new line and make the output of program clearly.
return 0;
}
Suggestion:
1. I didn’t know how to make the program runs smoothly when enter two times of “C”. After
many trials and error, I finally succeeded in using “Cpay=cpay+Cpay”, and “nc++” to
increase the amount of commission worker’s pay in the final table. (The other workers’
problem was solved by the same way.)
2. I don’t want this question in my exam because the time of the exam is limited. But this
assignment takes me a long time to finish.
3. In the beginning, I use the “static_cast” to make the result in a two decimal number, but it
shows if the result is an integer, it will not display “.00”, so I change it to the
“setprecision(2)” to keep the decimal number 0.
4. I learnt how to make a table which looks similar to the requirement of assignment by using
“setw()”.
5. I learnt how to use “\n” to start a new line and make the output of program clearly.