Computer Science, asked by Abhi5u7, 1 year ago

Write a menu driven program to calculate the sum, difference, product and quotient of the two numbers entered by user.

Answers

Answered by dikshaverma4you
9
Hey, I am providing a  C++ program. Kindly have a look over it. Hope it helps you. :-)

#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{ 
  clrscr();
   
  int x,z,c;
 
   char y,n,a,s,m,d,ch,choice;

   A:   
   cout<<"**********WELCOME TO ABHI'S WORLD**********"<<endl;
       cout<<"####### CALCULATE SIMPLE OPERATIONS HERE ####### "<<endl;   cout<<"Enter two numbers for calcuation( integers) "<<endl;   
 cin>>x>>z;
 { 

   cout<<" MENU DRIVEN PROGRAM "<<endl;
   
   cout<<" Press a  : For addition"<<endl;
 
   cout<<" Press s  : For subtraction"<<endl;
   
   cout<<" Press m : For multiplication"<<endl;
   
   cout<<" Press d  : For division"<<endl;
   cin>>choice;
 }
 
  if(choice=='a')
  { 
    c=x+z;
 
    cout<<"The sum of"<<x<<"and"<<z<<"is"<<c<<endl;
 }
  if(choice=='s')
{
  c=x-z;
  cout<<"The difference of"<<x<<"and"<<z<<"is"<<c<<endl;
 }
  if(choice=='m')
{ 
  c=x*z;
 
  cout<<"The product of"<<x<<"and"<<z<<"is"<<c<<endl;
}
  if(choice=='d')
 {
   c=x/z; 
  cout<<"The quotient of"<<x<<"and"<<z<<"is"<<c<<endl;
}
cout<<"Wanna perform the operation again??"<<endl;
cin>>ch;
if(ch=='y')
{ 
goto A;
}
if(ch=='n')
{ 
exit(0);
} 
getch();
}
Answered by CopyThat
3

Program: {JAVA}

import java.util.*;

public class Brainly

{

static void main()

{

Scanner sc=new Scanner(System.in);

float a,b,c;

int ch;

System.out.println("Enter 2 numbers:");

a=sc.nextFloat();

b=sc.nextFloat();

System.out.println("MENU");

System.out.println("1. to find the SUM");

System.out.println("2. to find the DIFFERENCE");

System.out.println("3. to find the PRODUCT");

System.out.println("Enter your choice:");

ch=sc.nextInt();

switch(ch)

{

case 1:

c=a+b;

System.out.println("Sum="+c);

break;

case 2:

c=a-b;

System.out.println("Difference="+c);

break;

case 3:

c=a*b;

System.out.println("Product="+c);

break;

default:

System.out.println("Invalid Choice!");

}

}

}

Similar questions