Write a C++ program called \"assignment4.cpp\" that will implement a menu for th
ID: 3606673 • Letter: W
Question
Write a C++ program called "assignment4.cpp" that will implement a menu for the user to choose between “grade calculation” (refer to Assignment#2) or “banking activity” (refer to Assignment#3). The program should also check for valid inputs (using loops). The program would allow user to perform the chosen activity multiple times (implement loops) based on the user input. In addition to this, all specifications for “grade calculation” (Assignment#2) and “banking activity” (Assignment#3) would also apply.
• In your program you are expected to use conditional (IF-ELSE/SWITCH/CONDITIONAL OPERATORS) statements, loops (FOR/WHILE/DO-WHILE) and other decision control statements, and input/output objects that you have already learned about.
• The program starts with a menu for the user to choose between the “grade calculation” or “banking activity” • You are also expected to check for valid inputs (using a loop) and should print out error messages if invalid inputs are entered.
• Based on their choice, they are prompted to enter the number of times (less than 10) they want to calculate a grade or perform transactions in their bank account • You are expected to implement loops that will run only a finite number of times.
• In addition to above specifications, you are expected to follow all specifications for “grade calculation” (Assignment#2) and “banking activity” (Assignment#3).
• BONUS 5 POINTS on this assignment will be given to those who will implement break and continue statements in their code.
Sample Output Below are sample outputs with input in bold and underlined. Your output does not need to match directly.
Sample 1
CSE 100 ASSIGNMENT 4
What would you like to do today?
1) Calculate Grades for Students
2) Perform Banking Activity Your choice is 1
WELCOME TO GRADE CALCULATIONS
You are only allowed to calculate grades for up to 10 students at a time
How many students would you like to calculate the grades for?
You entered 12 Error!!! Wrong number!!! Want to try again?
How many students would you like to calculate the grades for?
You entered 2
Enter the Student’s Quiz Score: 15
Error!!! Quiz score can not be more than 10!!!
Enter a valid Quiz Score for the student 8
Enter the Student’s
Pre Class Activity Score: 2.2
Enter the Student’s In Class Activity Score: 2.4
Enter the Student’s Lab Score: 13.9
Enter the Student’s Assignment Score: 18.5
Enter the Student’s Test Score: 47
You total calculated score is: 92.00
The letter grade you will be assigned for the course is:
A Enter the Student’s Quiz Score:
………
…..
…..
The letter grade you will be assigned for the course is:….
Sample 2
CSE 100 ASSIGNMENT 4
What would you like to do today?
1) Calculate Grades for Students
2) Perform Banking Activity
Your choice is 2
WELCOME TO SBC BANK
How many transactions would you like to do today?
You entered 3
What would you like to do now?
1) Deposit
2) Withdraw
3) Transfer
4) Display Balance
Your choice is 2
Please choose the account
C for Checking
S for Savings
Your choice is C
Please enter the amount you would like to transfer-$ 800.87
!!!You have entered an invalid amount!!! You do not have available balance for this withdrawal!!!
Your available balance in this account is $200
Please enter an amount less than that- $ 113.50
Your current balance in Checking Account is $86.50
Your current balance in Savings Account is $800.00
What would you like to do now?
1) Deposit
2) Withdraw
3) Transfer
4) Display Balance
……..
……..
……..
Explanation / Answer
Source Code:
--------------------------
#include<iostream>
using namespace std;
#define MAX 10
class Bank_Account
{
public:
int balance=500;
public:
void deposit()
{
cout<<"Enter Deposit amount :-";
int deposit=0;
cin>>deposit;
deposit=deposit+balance;
cout<<" Deposit Balance = "<<deposit;
balance=deposit;
}
public:
void withdrawal()
{
int withdraw;
cout<<" Available Amount is"<<balance;
cout<<" Enter Withdraw Amount :-";
cin>>withdraw;
if(withdraw>balance)
{
cout<<"!!Error Unable To WithDraw"<<endl;
cout<<"Available Amount is:"<<balance<<endl;
cout<<"Please Enter Correct Amount:"<<endl;
}
else
{
balance=balance-withdraw;
cout<<"After Withdraw Balance is "<<balance;
}
}
public:
void Balance_Enquiry()
{
cout<<" Available Balance is:"<<balance<<endl;
}
};
int main()
{
Bank_Account obj;
int option,length;
int Score;
double pre_score,in_score,lab_score,Assign_Score,Test_Score;
double total=0;
cout<<" *** Banking system And Student Grades *** "<<endl;
cout<<"CSE 100 ASSIGNMENT 4 "<<endl;
while(true)
{
cout<<"What would you like to do today? "<<endl;
cout<<"1).Calculate Grades for Students "<<endl;
cout<<"2).Perform Banking Activity "<<endl;
cout<<"3).Exit "<<endl;
cout<<"please enter Your Choice: "<<endl;
cin>>option;
if(option==1)
{
cout<<"-----------------------------------------"<<endl;
cout<<"***Welcome to Student Grade Calculations ****"<<endl;
label:
cout<<"How many students would you like to calculate the grades for?"<<endl;
cin>>length;
if(length>MAX)
{
cout<<"You have Entered "<<length<<endl;
cout<<"!Wrong Number Try Again"<<endl;
goto label;
}
else
{
int i=0;
cout<<"You have Entered "<<length<<endl;
while(i<length)
{
cout<<" Enter The Student Quiz Score:"<<endl;
cin>>Score;
if(Score>10)
{
cout<<"Error!!! Quiz score can not be more than 10!!!"<<endl;
cout<<" Please Try Again"<<endl;
continue;
}
else
{
cout<<" Enter the Student’s Pre Class Activity Score"<<endl;
cin>>pre_score;
cout<<" Enter the Student’s In Class Activity Score:"<<endl;
cin>>in_score;
cout<<" Enter the Student’s Lab Score:"<<endl;
cin>>lab_score;
cout<<" Enter the Student’s Assignment Score:"<<endl;
cin>>Assign_Score;
cout<<" Enter the Student’s Test Score:"<<endl;
cin>>Test_Score;
total=total+(Score+pre_score+in_score+lab_score+Assign_Score+Test_Score);
cout<<" total calculated score is:"<<total;
if(total>90)
{
cout<<" The letter grade you will be assigned for the course is:A"<<endl;
}
else if (total>70&&total<80)
{
cout<<" The letter grade you will be assigned for the course is:B"<<endl;
}
else if(total>50&&total<70)
{
cout<<"The letter grade you will be assigned for the course is:C"<<endl;
}
else
{
cout<<"The letter grade you will be assigned for the course is:D"<<endl;
}
total=0;
}
i++;
}
}
}
else if(option==2)
{
cout<<"--------------------------------- "<<endl;
cout<<"******WELCOME TO SBC BANK ******** "<<endl;
cout<<"--------------------------------- "<<endl;
while(true)
{
cout<<" ********** Menu ***********"<<endl;
cout<<"1) Deposit"<<endl;
cout<<"2) Withdraw"<<endl;
cout<<"3) Display Balance"<<endl;
cout<<"4) Transfer"<<endl;
cout<<"5).Exit"<<endl;
cout<<" What would you like to do now?"<<endl;
cin>>option;
switch(option)
{
case 1:
obj.deposit();
break;
case 2:
obj.withdrawal();
break;
case 3:
obj.Balance_Enquiry();
break;
case 4:
obj.Balance_Enquiry();
break;
case 5:
exit(0);
default:
cout<<"Invalid Option!"<<endl;
}
}
}
else if(option==3)
{
cout<<"Exit"<<endl;
exit(0);
}
else
{
cout<<" !Wrong Option Choosen:"<<endl;
cout<<"Please Try Again "<<endl;
continue;
}
}
}
Sample output:
-------------------------
*** Banking system And Student Grades ***
CSE 100 ASSIGNMENT 4
What would you like to do today?
1).Calculate Grades for Students
2).Perform Banking Activity
3).Exit
please enter Your Choice:
1
-----------------------------------------
***Welcome to Student Grade Calculations ****
How many students would you like to calculate the grades for?
15
You have Entered 15
!Wrong Number Try Again
How many students would you like to calculate the grades for?
3
You have Entered 3
Enter The Student Quiz Score:
10
Enter the StudentÆs Pre Class Activity Score
10
Enter the StudentÆs In Class Activity Score:
20
Enter the StudentÆs Lab Score:
30
Enter the StudentÆs Assignment Score:
40
Enter the StudentÆs Test Score:
15
total calculated score is:125
The letter grade you will be assigned for the course is:A
Enter The Student Quiz Score:
10
Enter the StudentÆs Pre Class Activity Score
1
Enter the StudentÆs In Class Activity Score:
2
Enter the StudentÆs Lab Score:
3
Enter the StudentÆs Assignment Score:
4
Enter the StudentÆs Test Score:
5
total calculated score is:25
The letter grade you will be assigned for the course is:D
Enter The Student Quiz Score:
10
Enter the StudentÆs Pre Class Activity Score
10
Enter the StudentÆs In Class Activity Score:
20
Enter the StudentÆs Lab Score:
30
Enter the StudentÆs Assignment Score:
10
Enter the StudentÆs Test Score:
10
total calculated score is:90The letter grade you will be assigned for the course is:D
What would you like to do today?
1).Calculate Grades for Students
2).Perform Banking Activity
3).Exit
please enter Your Choice:
2
---------------------------------
******WELCOME TO SBC BANK ********
---------------------------------
********** Menu ***********
1) Deposit
2) Withdraw
3) Display Balance
4) Transfer
5).Exit
What would you like to do now?
1
Enter Deposit amount :-1000
Deposit Balance = 1500
********** Menu ***********
1) Deposit
2) Withdraw
3) Display Balance
4) Transfer
5).Exit
What would you like to do now?
2
Available Amount is1500
Enter Withdraw Amount :-2000
!!Error Unable To WithDraw
Available Amount is:1500
Please Enter Correct Amount:
********** Menu ***********
1) Deposit
2) Withdraw
3) Display Balance
4) Transfer
5).Exit
What would you like to do now?
3
Available Balance is:1500
********** Menu ***********
1) Deposit
2) Withdraw
3) Display Balance
4) Transfer
5).Exit
What would you like to do now?
5
--------------------------------
Process exited after 52.5 seconds with return value 0
Press any key to continue . . .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.