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

In Eclipse C++ code please. 1. Add a manual selection that interfaces with the u

ID: 3577984 • Letter: I

Question

In Eclipse C++ code please.

1. Add a manual selection that interfaces with the user to your program. Add a user selectionmenu at the beginning of your program. You can use either switch or if else if statement todo so.

2. The user interface:

Enter your name: Tom Waits (example)

Hello Tom Waits, please select the service: A: Investment projection B: Retirement planning C: Mortgage D: College fund E: Exit

If user select A, execute your lab 3 program.

If the user select E, output “Thank you.”

If the user select anything else, output “Invalid selection.”

3. Check to make sure that the user is input ONLY ABCDE or abcde

4. When the user finish transaction, prompt the user for another transaction, if the user enter N,end with “Have a nice day.”

5. Under (D), Prompt the user to enter:

Please enter the following:

Principle:

Interest rate:

After the user finish entering, output the following:

Hello Tom Waits:
Principle:                                                xxxx

Interest rate:                                            xxxx

Saving period (in month):                       X month

Net worth after X years:                          xxxx

Would you like to go back to Menu? (Y/N)

(both Y or y, N or n are accepted.)

6. When the user finish transaction, prompt the user for another transaction, if the user enter N,end with “Have a nice day.”

7. Under College fund (D), read “OptD.txt ” and input information for calculation. Each number represents one month of contribution. Therefore, sum every 12 month together forget yearly savings, and use your numbers you get from option D. Display the calculatedresults and output to a “College_fund.txt”

Explanation / Answer

Solution:

C++ Code:

#include <cstdlib>
#include <iostream>
#include <fstream>
#include<sstream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char** argv) {

string name, line, lineStr;
char choice, option;
double lineData, interest, principalAmt, tenure, Payment;

ifstream myfile("OptD.txt");

cout << "Enter your name : ";
cin >> name;

cout << "Hello " << name << " ,Please Select the Service : " << endl;

while (true)
{
  
   cout << "Please Select the Service : " << endl;
   cout << " --------------------------------------" << endl;
   cout << "A: Investment projection. B: Retirement planning. C: Mortgage. D: College fund. E: Exit." << endl;

   cin >> choice;

   if (choice == 'A' || choice == 'a')
   {
      
       cout << "Need to add the Lab 3 Program.!" << endl;
       cout << "Would you like to go back to Menu?" << endl;
       cin >> option;
       if (option == 'y' || option == 'Y')
       {
       continue;
       }
       else if (option == 'n' || option == 'N')
       {
           cout << "Have a nice day." << endl;
           break;
       }
   }
   else if (choice == 'B' || choice == 'b')
   {
          
       cout << "Service Coming Soon.!" << endl;
       cout << "Would you like to go back to Menu?" << endl;
       cin >> option;
       if (option == 'y' || option == 'Y')
       {
       continue;
       }
       else if (option == 'n' || option == 'N')
       {
       cout << "Have a nice day." << endl;
       break;
       }
   }
   else if (choice == 'D' || choice == 'd')
   {
      
       int count = 0;
       double prin,rateofinterest;
       cout<<"Principle: "<<endl;
       cin>>prin;
       cout<<"Rate of Interest :"<<endl;
       cin>>rateofinterest;
       double save[100];
       double savings=0.00;
       double princple=0.0;
       if (myfile.is_open())
       {
              
           while (getline(myfile, line))
           {
               istringstream ss(line);
               ss>>save[count];
               count++;
           }
      
           for(int k=0;k<count;k++)
           {
               savings=savings+save[k];
               princple=savings*(1+(prin*(rateofinterest/12)));
               savings=princple;

           }
      
           cout << "Hello " << name << endl;
           cout << "Principal : " << prin << endl;
           cout << "Interest Rate : " << rateofinterest << endl;
           cout << "Saving Period: " << count << endl;
           cout << "Net worth after "<<count<<"yeras: " << savings << endl;

           myfile.close();
       }
       else
       {
       cout << "Unable to open file";
       }
       cout << "Would you like to go back to Menu?" << endl;
       cin >> option;
       if (option == 'y' || option == 'Y')
       {
       continue;
       }
       else if (option == 'n' || option == 'N')
       {
       cout << "Have a nice day." << endl;
       break;
       }
   }
   else if (choice == 'C' || choice == 'c')
   {
      
       cout << "Service Coming Soon.!" << endl;
       cout << "Would you like to go back to Menu?" << endl;
       cin >> option;
       if (option == 'y' || option == 'Y')
       {
          
           continue;
       }
       else if (option == 'n' || option == 'N')
       {
           cout << "Have a nice day." << endl;
           break;
       }
   }
   else if (choice == 'E' || choice == 'e')
   {
      
       cout << "Thank you." << endl;
       cout << "Would you like to go back to Menu?" << endl;
       cin >> option;
       if (option == 'y' || option == 'Y')
       {
           continue;
       }
       else if (option == 'n' || option == 'N')
       {
           cout << "Have a nice day." << endl;
           break;
       }
       }
       else
       {
           cout << "Invalid Selection." << endl;
           continue;
       }
}
return 0;
}

Output:

Enter your name : Drisya
Hello Drisya ,Please Select the Service :
Please Select the Service :

--------------------------------------
A: Investment projection.
B: Retirement planning.
C: Mortgage.
D: College fund.
E: Exit.
D
Principle:
1000
Rate of Interest :
10
Hello Drisya
Principal : 1000
Interest Rate : 10
Saving Period: 3
Net worth after 3yeras: 5.81486e+010
Would you like to go back to Menu?