ICSE Computer
Applications Question Paper 2019 Solved for Class 10
Question
5.
Using
the switch-case statement, write a menu driven program to do the following:
[15]
(a)
To generate and print Letters from A to Z and
their Unicode
Letters Unicode
A 65
B 66
. .
. .
Z 90
(b)
Display the following pattern using iteration
(looping):
1
1
2
1 2 3
1 2 3 4
1 2 3 4 5
JAVA CODE
import java.util.*;
public class
ICSEB5 {
public
static void main(String[] args) {
Scanner input = new
Scanner(System.in);
int choice;
System.out.println("Press 1 for Unicode and 2 for Pattern:");
System.out.println("Please enter your choice:");
choice = input.nextInt();
switch(choice) {
case
1:
unicodeLetters obj = new
unicodeLetters();
obj.generateUnicode();
break;
case
2:
numberPattern ob = new
numberPattern();
ob.generatePattern();
break;
default:
System.out.println("INVALID CHOICE:");
break;
}
input.close();
}
}
class unicodeLetters
{
public
void generateUnicode() {
System.out.println("Letters Unicode");
for(int i=65;i<=90;i++)
System.out.println((char)i+" "+i);
}
}
class numberPattern
{
public
void generatePattern() {
for(int i=1;i<=5;i++) {
for(int j=1;j<=i;j++)
System.out.print(j+" ");
System.out.println();
}
}
}
PYTHON CODE
No comments:
Post a Comment