AnshM 9DCA Term2Project
AnshM 9DCA Term2Project
Term 2
Grade: 9D
Roll No. 18
9D
PROGRAM 1
Question 1:
Write a menu driven program to
•display the largest as well as the smallest integer amongst all the integers entered.
•find the sum of two-digit as well as three-digit numbers separately for all the integers entered.
Take the number of integers and the integers as input from the user.
Code:
import java.util.Scanner;
int n = sc.nextInt();
int high=0;
int sum2 = 0;
int sum3 = 0;
if(i==1)
high = num;
low = num;
if(num>=high)
high = num;
if(num<=low)
low=num;
sum3= sum3+num;
System.out.println("Enter \'1\' to view the smallest and biggest number in the integers and \n\'2\' to find the sum of all 2 digit and 3 digit
numbers separately");
int ch = sc.nextInt();
switch(ch)
case 1:
break;
case 2:
break;
default:
Output:
Case 1 Case 2
Question 2:
Write a menu driven program to find the sum of following series
i)s=1*3 + 2*4 + 3*5 +....... + 6*8 + 7*9 +....... m*n (Take m and n as input from user)
Code:
import java.util.Scanner;
System.out.println("Enter '1' for the first sum series and '2' for the second sum series");
int ch = sc.nextInt();
double sum;
int m,n;
switch(ch)
{
case 1:
m = sc.nextInt();
n = sc.nextInt();
sum = 0;
break;
case 2:
sum = 0;
m = sc.nextInt();
if(i%2!=0)
else
break;
default:
}
Output:
Case 1 Case 2