Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the program in assignment 3 to handle data input for the principal, annua

ID: 3607011 • Letter: M

Question

Modify the program in assignment 3 to handle data input for the principal, annual
interest rate, and number of months from the keyboard. Use appropriate prompting
messages, such as: "Enter the annual interest rate:"
The program user should enter 10 for 10% interest, 8 for 8% interest, etc. You will
have to divide whatever the user enters by 100 or multiply by .01 to covert the
interest rate to a decimal to get the correct results in your calculations.
(I = P * R/10/12 * T)

this was the program i summited ... he said this this was needed ...prog04 variables should be type float.

#include <iostream>

using namespace std;

int main()
{
int t,r,p;//declaring variables
cout << "Enter the prinicpal amount:" ; //prompting for input
cin>>p;//scanning the entered input
cout<<p<<endl;
cout << "Enter the annual interest rate:" ;
cin>>r;
cout<<r<<endl;
cout << "Enter the number of months:" ;
cin>>t;
cout<<t<<endl;
double i=p*(0.01*r/12)*t;//calculating interest
cout<<"Total Interest is :"<<i<<endl;//printing result
return 0;
}

Explanation / Answer

#include <iostream>
using namespace std;
int main()
{
//int t,r,p;//declaring variables,if yu declare variable as int, it will not store decimal values
float t,r,p;//declaring as float to store decimals as well
cout << "Enter the prinicpal amount:" ; //prompting for input
cin>>p;//scanning the entered input
cout<<p<<endl;
cout << "Enter the annual interest rate:" ;
cin>>r;
cout<<r<<endl;
cout << "Enter the number of months:" ;
cin>>t;
cout<<t<<endl;
double i=p*(0.01*r/12)*t;//calculating interest
cout<<"Total Interest is :"<<i<<endl;//printing result
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote