
Explain the code below.
#include <iostream>
using namespace std;
string USERNAME[20] ={"Rey","Jasper","Paula"};
string PASSWORD[20] ={"Castillo","Agustin","Mendoza"};
int balance[20] = {500000, 50000, 5000};
int usernumber;
int decreaseBalance(){
int x;
cout << "\nHow much do you want to withdraw? ";
cin >>x;
cout << "\nPhp" << x << "has been reduced from your account";
return x;}
int increaseBalance(){
int x;
cout << "\nHow much do you want to deposit? ";
cin >>x;
cout << "\nPhp" << x << "has been added to your account" ;
return x;}
void checkBalance(int x){
cout << "\n\nYour balance is: " << "Php" <<x;}
bool login(){
system("cls");
string username;
string password;
cout << "USERNAME: ";
cin >> username;
cout << "\nPASSWORD: ";
cin >> password;
for(int i = 0; i < 20; i++){
if((username.compare(USERNAME[i]) == 0)
&& (password.compare(PASSWORD[i]) == 0)){
usernumber = i;
return true;} }
return false;}
main(){
bool exit = false;
cout << "Welcome to BankO!\n";
while(exit != true){
int choice;
do{
cout << "\n\n[0] LOG IN\n[1] exit\n";
cin >> choice;
}while(!(choice == 1 || choice == 0));
if(choice == 0){
bool valid = login();
if(valid){
cout << "Hello! " <<
USERNAME[usernumber];
bool cancel = false;
while(!(cancel)){
int option;
do{
cout << "\n[0] Deposit\n[1] Widthraw" <<
"\n[2] Check Balance\n[3] LOG OUT \n";
cin >> option;
}while(!(option >= 0 || option<= 3));
switch(option){
case 0:
balance[usernumber] += increaseBalance(); break;
case 1:
balance[usernumber] -= decreaseBalance(); break;
case 2:
checkBalance(balance[usernumber]); break;
default: cancel = true;
break;}
}
}
else
cout << "INVALID ACCOUNT!";
}
else
exit = true;
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- #include <iostream> using namespace std; int times(int mpr, int mcand) { int prod = 0; while (mpr != 0) { if (mpr % 2 == 1) prod = prod + mcand; mpr /= 2; mcand *= 2; } return prod; } int main(){ int n, m; cout << "Enter two numbers: "; cin >> n >> m; cout << "Product: " << times(n, m) << endl; return 0; } convert the following c++ code into pep/9 assembly languagearrow_forward#include <iostream> #include <string> using namespace std; int main() { // Declare and initialize variables. string employeeFirstName; string employeeLastName; double employeeSalary; int employeeRating; double employeeBonus; const double BONUS_1 = .25; const double BONUS_2 = .15; const double BONUS_3 = .10; const double NO_BONUS = 0.00; const int RATING_1 = 1; const int RATING_2 = 2; const int RATING_3 = 3; // This is the work done in the housekeeping() function // Get user input cout << "Enter employee's first name: "; cin >> employeeFirstName; cout << "Enter employee's last name: "; cin >> employeeLastName; cout << "Enter employee's yearly salary: "; cin >> employeeSalary; cout << "Enter employee's performance rating: "; cin >> employeeRating; // This is the work done in the detailLoop() function // Use switch statement to…arrow_forward#include <iostream>using namespace std; double average(int sum_of_grades,int num_grades){return sum_of_grades/(float)num_grades;} int main() {int num_grades,grade,sum=0;char grade_value;cout<<"Enter the number of grades"<<endl;cin>>num_grades;for(int i=0;i<num_grades;i++){cout<<"Enter a numeric grade between 0-100"<<endl;cin>>grade;sum+=grade;}double avg=average(sum,num_grades);if(avg>=90 && avg<=100)grade_value='A';else if(avg>=80 && avg<=89)grade_value='B';else if(avg>=70 && avg<=79)grade_value='C';else if(avg>=60 && avg<=69)grade_value='D';else if(avg>=0 && avg<=59)grade_value='F';cout<<"The grade is "<<grade_value;} review if the written c++ code is correct then organize the code and write comments for each part of the program explaining what they do.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





