Java Lecture 3
Java Lecture 3
Lecture 3
int n = 1;
switch(n) {
case 1 :
System.out.println("Monday");
break;
case 2 :
System.out.println("Tuesday");
break;
case 3 :
System.out.println("Wednesday");
break;
case 4 :
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6 :
System.out.println("Saturday");
break;
default :
System.out.println("Sunday");
}
Apna College
Homework Problems
1. Make a Calculator. Take 2 numbers (a & b) from the user and an
operation as follows :
1 : + (Addition) a + b
● 2 : - (Subtraction) a - b
● 3 : * (Multiplication) a * b
● 4 : / (Division) a / b
● 5 : % (Modulo or remainder) a % b
2. Ask the user to enter the number of the month & print the name
of the month. For eg - For ‘1’ print ‘January’, ‘2’ print ‘February’ &
so on.
Apna College