In Python Programming Assignments: 1. 2. Add a manual selection that interfaces
ID: 3734755 • Letter: I
Question
In Python Programming
Assignments: 1. 2. Add a manual selection that interfaces with the user to your program. Add a user selection menu at the beginning of your program. The user interface: Enter your name: Tom Waits (example) Hello Tom Waits, please select the service: A: Investment proiection B: Retirement planning C: Mortgage D: Collee fundE: Exit If user select A or a, execute your lab A program. Ifthe user select B.b D or d. output " service coming soon." If the user select E or e, output "Thank you." If the user select anything else, output "Invalid selection." 3. Check to make sure that the user is ipur ONL Y ABCDE or abede, when invald selection is 4. When the user finish transaction, prompt the user for another transaction, if the user enter N made, bring the user back to selection. end with "Have a nice day."Explanation / Answer
python program
#include <cstdlib> // required header files
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
int main(int argc, char** argv) { // driver method
string name, line, lineStr; // local varaibles
char choice, option;
double lineData, interest, principalAmt, tenure, Payment;
ifstream myfile("load.txt"); // loading the data
cout << "Enter your name : "; // get the name of the user
cin >> name;
cout << "Hello " << name << " ,Please Select the Service : "
<< endl; // print the message
while (true) { // loop over the data
cout << "Please Select the Service : " << endl; // message
about the code
cout << " --------------------------------------" << endl;
cout << "A: Investment projection. B: Retirement
planning. C: Mortgage. D: College fund. E: Exit." <<
endl;
cin >> choice; // get the choice
if (choice == 'A' || choice == 'a') { // check for the choice
cout << "Need to add the Lab 3 Program.!" << endl; //
message to console
cout << "Would you like to go back to Menu?" << endl; //
ask for the option
cin >> option; // get the option
if (option == 'y' || option == 'Y') { // check the data
continue;
} else if (option == 'n' || option == 'N'){
cout << "Have a nice day." << endl; // end if not needed
break;
}
} else if (choice == 'B' || choice == 'b') { // check for the
choice
cout << "Service Coming Soon.!" << endl; // message to
console
cout << "Would you like to go back to Menu?" << endl; //
ask for the option
cin >> option; // get the option
if (option == 'y' || option == 'Y') { // check the data
continue;
} else if (option == 'n' || option == 'N'){
cout << "Have a nice day." << endl; // end if not needed
break;
}
} else if (choice == 'C' || choice == 'c') { // check for the
choice
int count = 0;
if (myfile.is_open()) { // check for the file
while (getline(myfile, line)) {
count++;
size_t pos = line.find(":"); // seperate the data from the
strings
lineStr = line.substr(pos + 1); // get the required data
lineData = atof(lineStr.c_str()); // convert to double type
if (count == 1) { // read every data line
principalAmt = lineData;
} else if (count == 2) {
interest = lineData;
} else if (count == 3) {
tenure = lineData;
}
double MonthlyInt = interest / 12; // calculations for the
interest and the payments
double NumPayments = tenure * 12;
Payment = MonthlyInt pow((1 + MonthlyInt),
NumPayments) / (pow((1 + MonthlyInt), NumPayments) –
1) principalAmt; // calculations for the amount
}
cout << "Hello " << name << endl; // print data to console
cout << "Principal Amount : " << principalAmt << endl;
cout << "Interest Rate : " << interest << endl;
cout << "Loan Term : " << tenure << endl;
cout << "The Monthly Mortgage is : " << Payment <<
endl;
myfile.close(); // close the file
} 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; // end if not needed
break;
}
} else if (choice == 'D' || choice == 'd') { // check for the
choice
cout << "Service Coming Soon.!" << endl;
cout << "Would you like to go back to Menu?" << endl; //
message to console
cin >> option;
if (option == 'y' || option == 'Y') { // check for the choice
continue;
} else if (option == 'n' || option == 'N') {
cout << "Have a nice day." << endl; // end if not needed
break;
}
} else if (choice == 'E' || choice == 'e') { // check for the choice
cout << "Thank you." << endl;
cout << "Would you like to go back to Menu?" << endl; //
message to console
cin >> option;
if (option == 'y' || option == 'Y') {
continue;
} else if (option == 'n' || option == 'N'){
cout << "Have a nice day." << endl; // end if not needed
break;
}
} else {
cout << "Invalid Selection." << endl; // mesage and then
continue
continue;
}
}
return 0;
}
OUTPUT:
Enter your name : John
Hello John ,Please Select the Service :
Please Select the Service :
--------------------------------------
A: Investment projection.
B: Retirement planning.
C: Mortgage.
D: College fund.
E: Exit.
a
Need to add the Lab 3 Program.!
Would you like to go back to Menu?
y
Please Select the Service :
--------------------------------------
A: Investment projection.
B: Retirement planning.
C: Mortgage.
D: College fund.
E: Exit.
b
Service Coming Soon.!
Would you like to go back to Menu?
y
Please Select the Service :
--------------------------------------
A: Investment projection.
B: Retirement planning.
C: Mortgage.
D: College fund.
E: Exit.
x
Invalid Selection.
Please Select the Service :
--------------------------------------
A: Investment projection.
B: Retirement planning.
C: Mortgage.
D: College fund.
E: Exit.
d
Service Coming Soon.!
Would you like to go back to Menu?
y
Please Select the Service :
--------------------------------------
A: Investment projection.
B: Retirement planning.
C: Mortgage.
D: College fund.
E: Exit.
c
Hello John
Principal Amount : 500000
Interest Rate : 0.12
Loan Term : 5
The Monthly Mortgage is : 11122.2
Would you like to go back to Menu?
e
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.