Copyrighted By @Curious_Coder
JAVA PROGRAMS
WITH OUTPUT
Copyrighted By @Curious_Coder
, Copyrighted By @Curious_Coder
Program no 1
1) WAP using nested switch case which
covers the following operators with
expressions :
(a) Mathematical
(b) Logical
(c) Relational
PROGRAMME:- A
public class Switch{
public static void main(String []args){
System.out.println("1.ARITHMATIC
OPERATORS\n2.LOGICAL OPERATORS\n3.RELATIONAL
OPERATORS\n\t\t(Choice=1)\n"); //Main menu
int choice=1;
int a=10,b=5,c;
switch(choice) //Main switch case
{
, Copyrighted By @Curious_Coder
case 1 : //arithmatic operators
System.out.println("1.Addition\n2.Subtraction\n3.Multiplicati
on\n4.Division\nVALUES OF a AND b ARE 10 AND 5
RESPECTIVELY\n\t\t(Choice=3)\n");
int aChoice=3;
switch(aChoice) //Nested switch case
{
case 1: //addition
c=a+b;
System.out.println("Addtion of a and b is "+ c+"\n");
break;
case 2: //subtraction
c=a-b;
System.out.println("Subtraction of a and b is "+
c+"\n");
break;
, Copyrighted By @Curious_Coder
case 3: //Multiplication
c=a*b;
System.out.println("Multiplication of a and b is "+
c+"\n");
break;
case 4: //division
c=a/b;
System.out.println("Divisiom of a and b is "+ c+"\n");
break;
default:
System.out.println("Please enter right choice");
}
break;
case 2 : //logical operator
System.out.println("1.Logical AND\n2.LOgical OR\n3.NOT
Operator\n");
JAVA PROGRAMS
WITH OUTPUT
Copyrighted By @Curious_Coder
, Copyrighted By @Curious_Coder
Program no 1
1) WAP using nested switch case which
covers the following operators with
expressions :
(a) Mathematical
(b) Logical
(c) Relational
PROGRAMME:- A
public class Switch{
public static void main(String []args){
System.out.println("1.ARITHMATIC
OPERATORS\n2.LOGICAL OPERATORS\n3.RELATIONAL
OPERATORS\n\t\t(Choice=1)\n"); //Main menu
int choice=1;
int a=10,b=5,c;
switch(choice) //Main switch case
{
, Copyrighted By @Curious_Coder
case 1 : //arithmatic operators
System.out.println("1.Addition\n2.Subtraction\n3.Multiplicati
on\n4.Division\nVALUES OF a AND b ARE 10 AND 5
RESPECTIVELY\n\t\t(Choice=3)\n");
int aChoice=3;
switch(aChoice) //Nested switch case
{
case 1: //addition
c=a+b;
System.out.println("Addtion of a and b is "+ c+"\n");
break;
case 2: //subtraction
c=a-b;
System.out.println("Subtraction of a and b is "+
c+"\n");
break;
, Copyrighted By @Curious_Coder
case 3: //Multiplication
c=a*b;
System.out.println("Multiplication of a and b is "+
c+"\n");
break;
case 4: //division
c=a/b;
System.out.println("Divisiom of a and b is "+ c+"\n");
break;
default:
System.out.println("Please enter right choice");
}
break;
case 2 : //logical operator
System.out.println("1.Logical AND\n2.LOgical OR\n3.NOT
Operator\n");