NAME: ABC
CLASS:
SECTION:
ROLL NO.:
UID CODE:
REGISTRATION NO:
SUBJECT:COMPUTER PROJECT ASSIGNMENT
SCHOOL: ST. XAVIER’S INSTITUTION
,1. WRITE A MENU DRIVEN PROGRAM TO PRINT THE FOLLOWING SERIES:
a. 1,11,111, 1111, .nth term
b. 1,12,123, 1234, …. nth term
import java.util.*;
class prog1
{
public static void main(String[] args) {
int i,ch,n;
Scanner sc=new Scanner(System.in);
System.out.println("enter the value of n");
n=sc.nextInt();
System.out.println("MENU");
System.out.println("1. Series 1");
System.out.println("2. Series 2");
System.out.println("enter a choice");
ch=sc.nextInt();
switch (ch)
{
case 1: int s = 0; // s for terms of series, c for n terms
for (i = 1; i <= n; i++) // To generate n terms
{
s = s * 10 + 1;
System.out.print(s + " ");
}
break;
case 2: int s = 0 ; // s for terms of series, c for counter to generate n terms
for (i = 1; i <= n; i++)
{
s = s * 10 + c;
System.out.print(s + " ");
}
break;
default:
System.out.println("wrong choice");
}//end of switch
}//end of main
}//end of class
/*
enter the value of n
5
MENU
1. Series 1
2. Series 2
enter a choice
1
, 1 11 111 1111 11111
enter the value of n
5
MENU
1. Series 1
2. Series 2
enter a choice
2
1 12 123 1234 12345
*/
CLASS:
SECTION:
ROLL NO.:
UID CODE:
REGISTRATION NO:
SUBJECT:COMPUTER PROJECT ASSIGNMENT
SCHOOL: ST. XAVIER’S INSTITUTION
,1. WRITE A MENU DRIVEN PROGRAM TO PRINT THE FOLLOWING SERIES:
a. 1,11,111, 1111, .nth term
b. 1,12,123, 1234, …. nth term
import java.util.*;
class prog1
{
public static void main(String[] args) {
int i,ch,n;
Scanner sc=new Scanner(System.in);
System.out.println("enter the value of n");
n=sc.nextInt();
System.out.println("MENU");
System.out.println("1. Series 1");
System.out.println("2. Series 2");
System.out.println("enter a choice");
ch=sc.nextInt();
switch (ch)
{
case 1: int s = 0; // s for terms of series, c for n terms
for (i = 1; i <= n; i++) // To generate n terms
{
s = s * 10 + 1;
System.out.print(s + " ");
}
break;
case 2: int s = 0 ; // s for terms of series, c for counter to generate n terms
for (i = 1; i <= n; i++)
{
s = s * 10 + c;
System.out.print(s + " ");
}
break;
default:
System.out.println("wrong choice");
}//end of switch
}//end of main
}//end of class
/*
enter the value of n
5
MENU
1. Series 1
2. Series 2
enter a choice
1
, 1 11 111 1111 11111
enter the value of n
5
MENU
1. Series 1
2. Series 2
enter a choice
2
1 12 123 1234 12345
*/