Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add the ability to save data to a disk in one or more files. The menu(s) should give the user the option to save or

Add the ability to save data to a disk in one or more files. The menu(s) should give the user the option to save or retrieve data.

#include

#include

#include

using namespace std;

void initFormatting();

void printInterfaceMessage();

void processUserRequest();

void validateUserInput();

void calculateMonthlyBalance();

int main()

{

initFormatting();

printInterfaceMessage();

processUserRequest();

return 0;

}

void initFormatting()

{

cout.setf(ios::fixed); // currency format into 2 decimal points

cout.setf(ios::showpoint);

cout.precision(2);

}

void printInterfaceMessage()

{

cout << "Welcome national Bank " << endl;

cout << "We are please in assisting you in your banking needs" << endl;

cout << "Menu" << endl;

//cout << "Want to start or do you want to quit?"

// << " Enter '1' for start, or '2' to quit." << endl;

}

void processUserRequest()

{

/*int answer_1;*/

char ch = 'y';

// array holds start program input

char menu[2][28] = { "Menu: Start Process (s) " , "Menu: Quit the Process (q) " };

//while (true)

//{

// //Ask user if they want to start or quit

// cin >> answer_1;

// if (answer_1 >2)

// {

// cout << "Menu ";

// cout << " Enter '1' for start, and time 2. quit ";

// }

// else {

// break;

// }

//}

//if (answer_1 == 1)

//{

/* cout << "We are Open to start at this time " << endl;*/

while (ch == 'y' || ch == 'Y')

{

//user prompt for menu number

for (int i = 0; i < 2; i++)

{

cout << (i + 1) << ". " << menu[i] << endl;

}

validateUserInput();

calculateMonthlyBalance();

cout << "Press Enter to end -->" << endl;

}

system("pause");

}

void validateUserInput()

{

int choiNos[2] = { 1, 2 }, choice;

//validate user input in a loop

while (true)

{

bool valid = false;

cout << endl << "Please enter your choice number : ";

cin >> choice;

for (int i = 0; i < 2; i++)

{

if (choiNos[i] == choice)

{

valid = true;

break;

}

}

if (!valid)

{

cout << "Invalid entery!" << endl;

continue;

}

break;

}

}

void calculateMonthlyBalance()

{

double monthlyPayment;

double interestRate;

double loanAmount;

double month = 0;

double balance; //Balance due

// input

cout << "Enter the current balance of your loan: $";

cin >> loanAmount;

cout << "Enter the interest rate : ";

cin >> interestRate;

cout << "Enter the monthly payment : $";

cin >> monthlyPayment;

// calculate interst rate

while (interestRate >= 1)

{

interestRate = interestRate / 100;

}

balance = loanAmount* (1 + interestRate / 12) - monthlyPayment;

cout << "month 1 your balance is $" << balance << endl;

while (balance > 0)

{

balance = balance * (1 + interestRate / 12) - monthlyPayment;

month = month++;

cout << " month " << month << ", your balance is : $" << balance << endl;

}

system("pause");

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

What are the various types of benchmarking?

Answered: 1 week ago

Question

1. What would you do if you were Jennifer, and why?

Answered: 1 week ago

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago