Justine Amf · September 18, 2014 Writing Programs using selection conditional structures1. Write a program that calculates and displays the amount of money available in a bank deposit that initially has 50,000 deposited and earns interest at the rate of 3% a year. Your program should display the amount available at the end of each year for a period of 10 years. Use the relationship that the money available at the end of each year = the amount of money in the accout at the start of the year + 0.3 * the amount available at the start of the year.a. modify the program written to promt the user for both the amount of money initially deposited in the accountb. modify the program written to prompt the user for both the amount of money initially deposited and the number of years to be displayedc. modify the program written to prompt the user for both the amount of money initially deposited, the interest rate to be used and the number of years to be displayedive been working on this assignment in our programming class, and i can't seem to figure this out  TTplease help

## Replies

 Justine Amf · September 19, 2014 hey Mortaza Asaadi thank you for helping dumb students like me in making their homeworks, but i dont completely depend on others. I just find it helpful for me to know how other people code a certain program, bcoz we have different learnings & im still a beginner and i dont just copy, if that's what others want to say, but im trying my best really, to understand. And im very thankful for people who also tries their best to help M .A.K · September 18, 2014 This was once my homework some three years ago...And I didn't find any none obvious thing to add comments to! but yeah you are right... Eugene Botma · September 18, 2014 Mortaza Asaadi Please don't do other peoples homework assignments for them. How will she ever learn if you keep doing her work for her?Instead, guide her through solving the problem. If you really do need to show her code, at least explain the code properly using comments. M .A.K · September 18, 2014 added: Please try your best and then return here!1-``#include using namespace std;int main(){    cout.precision(5);//sets precision for every numeric cout output    double initial = 50000;    cout << "The initial deposite is "<< fixed << initial << "\$" << endl;//print initial value    for(int i = 1;i<=10;i++){//gonna run 10 times! 1,2,3,4,5,6,7,8,9,10      initial=(initial+(0.3*i));//mathematics!      cout << i <<" year and your deposite is "<< fixed << initial << "\$" << endl;      //fixed makes cout print floats with a fixed number of decimals    }}``a- initial can't be negative!``#include using namespace std;int main(){    cout.precision(5);    double initial; //now we need to get initial from user;    //cant let user to enter negative initial value    do{    cout<<"Please enter initial value: ";    cin >> initial;    //if initial value is negative this will be executed    if(initial<0){cout<<"Please enter proper number for initial value."<< endl;}    }while(initial<0);    cout << "The initial deposite is "<< fixed << initial << "\$" << endl;    for(int i = 1;i<=10;i++){      initial=(initial+(0.3*i));      cout << i <<" year and your deposite is "<< fixed << initial << "\$" << endl;    }}``b-Year can't be negative(obvious)!``#include using namespace std;int main(){     cout.precision(5);    double initial;    int years; //need to get number of years from user    do{    cout<<"Please enter initial value: ";    cin >> initial;    if(initial<0){cout<<"Please enter proper number for initial value."<< endl;}    }while(initial<0);    //years can't be negative!but user can enter 0 and see initial value    do{    cout<<"Please enter the number of years: ";    cin >> years;    if(years<0){cout<<"Please enter proper number for years."<< endl;}    }while(years<0);     for(int i = 0;i<=years;i++){//gonna run at least once     //takes care of i=0 to be printed properly     if(i==0){     cout << "The initial deposite is "<< fixed << initial << "\$" << endl;     }else{//will print all other years      initial=(initial+(0.3*i));      cout << i <<" year and your deposite is "<< fixed << initial << "\$" << endl;          }     }}``c- The complete program:``#include using namespace std;int main(){  cout.precision(5);    double initial,interest;  int years;    while(1){//program executes forever if user never exits!       do{      cout<<"Please enter initial value: ";      cin >> initial;      if(initial<0){cout<<"Please enter proper number for initial value."<< endl;}    }while(initial<0);        cout<<"Please enter the interest rate per year: ";    cin >> interest;       do{      cout<<"Please enter the number of years: ";      cin >> years;      if(years<0){cout<<"Please enter proper number for years."<< endl;}    }while(years<0);       for(int i = 0;i<=years;i++){     if(i==0){         cout << "The initial deposite is "<< fixed << initial << "\$" << endl;     }else{           initial=(initial+(0.3*i));           cout << i <<" year and your deposite is "<< fixed << initial << "\$" << endl;          }     }    //exit the program dumb(user)!    char ch;    cout << "Do you wanna exit the program?(y=yes) ";    cin >> ch;    if(ch == 'y'){break;}//this breaks from program execution      }    }``
• 1

## C++

118,077 followers

Used in many types of software including music players, video games, and many large scale applications.