Answer to Question #261259 in C++ for zain

Question #261259

1. Create a new project with following particulars

1.      name the project title in the following format “ID_section_lab#” e.g., “f2019065111_w1_lab2”.

2.      Create a menu to execute tasks. There shall be n tasks in total, update as they comes up. You should properly prompt wherever necessary. A sample menu is shown below.


1
Expert's answer
2021-11-04T16:25:58-0400
using namespace std;


#define NO_OF_TASKS	4


int main()
{
	float a,b,c;
	int i,Flag=1;
	
	while(Flag)
	{
		cout<<"\nPress 1 for Task-1 (Addition)";
		cout<<"\nPress 2 for Task-1 (Substraction)";
		cout<<"\nPress 3 for Task-1 (Multiplication)";
		cout<<"\nPress 4 for Task-1 (Division)";
		cout<<"\nPress 0 to QUIT";
		Flag=-1;
		while(Flag<0 || Flag>4)
		{
			cout<<"\nEnter Option (0 to 4): "; cin>>Flag;
		}
		
		cout<<"\nEnter first  number a = "; cin>>a;
		cout<<"\nEnter second number b = "; cin>>b;
		switch(Flag)
		{
			case(1):	c = a+b; cout<<"\nResult = "<<a<<" + "<<b<<" = "<<c;	break;
			case(2):	c = a-b; cout<<"\nResult = "<<a<<" - "<<b<<" = "<<c;	break;
			case(3):	c = a*b; cout<<"\nResult = "<<a<<" * "<<b<<" = "<<c;	break;
			case(4):	c = a/b; cout<<"\nResult = "<<a<<" / "<<b<<" = "<<c;	break;
			case(0):	break;
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS