Page 239 - ComputerScience_Class_11
P. 239
2. class Main {
public static void main(String[] args) {
int c=2;
switch(c)
{
case 1: System.out.print("one");
case 2: System.out.print("two");
break;
case 3: System.out.println("Wrong choice");
}
}
}
3. class Main {
public static void main(String[] args) {
int x=5,y=8,z=10;
if(x>y)
{
if(x>z)
{
System.out.println(x);
}
else
{
System.out.println(y);
}
}
else
{
if(y<z)
{
System.out.println(z);
}
else
{
System.out.println(y);
}
}
}
}
H. Unsolved Programs:
1. Write a Java program to input a number and print all the even digits and odd digits in the number separately.
2. Write a Java program to input a number and check whether it is divisible by 10 or not.
3. Write a Java program to print the following series:
a. 1+12+123+1234+……..+n term
th
b. S = a/1+a/2+c/3+…….+a/n
th
c. 1,4,9,16,……..., n term
d. 2+5+10+17+…….+n
th
e. 1*2*3*…….*n term
Statements and Scope 237

