Professional Documents
Culture Documents
COMPUTER APPLICATION
CLASS 9
SESSION-2021-2022
PG-1 pg. 1
NAME - PRAGYA HAZRA
CLASS - 9
SECTION – B
ROLL NUMBER – 19
UNIQUE ID NUMBER -
PG-1 pg. 2
INDEX
S.NO. PROGRAM NAME DATE PG.NO TEACHER’S SIGNATURE
1 Q.1 Given below is a 15.5.21 5-8
hypothetical table showing
rate of income tax for the
male citizens below the age
of 65 years:
taxable income in Rs[TI]
Income tax in Rs
Less than Rs 1, 60,000
NIL
Is greater than Rs 1,60,000
and less than or equal to
5,00,000
(TI-1,60,000)X10%
Is greater than Rs 5,00,000
and less than or equal to
8,00,000
[(TI-5,00,000)X20%]
+34000
Is greater than Rs 8,00,000
[(TI-8,00,000)X30%]
+94000
PG-1 pg. 3
etc)
3 Q.3 Canopy travels pvt ltd 14.5.21 11-13
gives following discount to its
customers:
Ticket amount
Discount
Above rs 70000
18%
Rs 55001 – rs 70,000
16%
Rs 35001 - 55000
12%
Rs 25001- 35000
10%
Less than 25000
2%
PG-1 pg. 4
sum of these greatest and
the smallest number found.
9 Q.9 Write a program to find 20.5.21 21
the square and cube of n
natural numbers ( n is
entered by the user)
10 Q.10 Write a program in 24.5.21 22-24
Java to print all the
Pythagorean triplets from 1
to 1000.
(Pythagorean triplets are the
numbers that satisfy
Pythagoras theorem eg 52 +
122 =132 ,so 5,12 and 13 are
Pythagorean triplet)
PG-1 pg. 5
QUESTION 1
Q.1 Given below is a hypothetical table showing rate of income tax for the male citizens below
the age of 65 years:
Write a program to input the age ,gender (male or female) and taxable income of the person.
If the age is more than 65 years or the gender is female ,display “WRONG CATEGORY”.If the
age is less than or equal to 65 years and the gender is male,then compute and display the income
tax payable as per the table .
import java.util.Scanner;
Coding:
char gen=in.next().charAt(0);
if(gen=='f'||gen=='F')
System.out.println("WRONG CATEGORY");
PG-1 pg. 6
else
double ti = in.nextDouble();
System.out.print("Wrong Category");
else {
tax = 0;
else
PG-1 pg. 7
TERMINAL WINDOW
QUESTION 2
Q.2 Write a program to input a number and check whether it is a PRONIC number or not.(A
PRONIC number is the product of two consecutive numbers,ex 12=3x4 , 20=4x5 etc)
Coding:
import java.util.Scanner;
PG-1 pg. 8
System.out.print("Input a number : ");
int ans = 0;
if(i*(i+1) == num)
ans = 1;
break;
if(ans == 1)
System.out.println("Pronic Number.");
else
TERMINAL WINDOW
PG-1 pg. 9
QUESTION 3
Q.3 Canopy travels pvt ltd gives following discount to its customers:
Ticket amount
Discount
Above rs 70000
18%
Rs 55001 – rs 70,000
PG-1 pg. 10
16%
Rs 35001 - 55000
12%
Rs 25001- 35000
10%
Less than 25000
2%
Write a program to input the name and the amount of ticket for the customer.Calculate the
discount and net amount to be paid.
Coding:
import java.util.Scanner;
String name[];
double amount[];
double discount=0,net=0;
int i=0;
name=new String[15];
amount=new double[15];
for(i=0;i<1;i++)
System.out.println("Customer:"+(i+1));
name[i] = sc.nextLine();
amount[i] = sc.nextDouble();
sc.nextLine();
PG-1 pg. 11
}
for(i=0;i<1;i++)
discount = 0.18*amount[i];
discount = 0.16*amount[i];
discount = 0.12*amount[i];
discount = 0.10*amount[i];
discount = 0.02*amount[i];
net=amount[i]-discount;
PG-1 pg. 12
System.out.println((i+1) + "\t" + name[i] +"\t" + amount[i] + "\t" + discount + "\t" + net);
TERMINAL WINDOW
QUESTION 4
Q.4 Write a java program to print all the 26 letters of English alphabet in Upper case using do
while loop.
Coding:
PG-1 pg. 13
class question4
char c='A';
do
System.out.println(c);
c++;
TERMINAL WINDOW:
QUESTION 5
Q5) Write a program in JAVA to print the multiplication table of 17 till 15.
Coding:
PG-1 pg. 14
class question5
int a=1;
while(a<=15)
a=a+1;
TERMINAL WINDOW
QUESTION 6
Q.6 Write a program in Java to check whether the number is even or odd using if else. Also use
do while loop in same program to terminate the program as soon as zero is entered by user.
Coding:
PG-1 pg. 15
import java.util.Scanner;
Scanner reader=new
Scanner(System.in);
System.out.print("ENTER A NUMBER:");
int num=reader.nextInt();
if(num%2==0)
else
TERMINAL WINDOW
QUESTION 7
Write a program in Java to check whether the number entered by the user is a prime number or
not.
Coding:
PG-1 pg. 16
{
int num=3;
boolean flag=false;
for(int i=2;i<=num/2;++i)
if(num% i==0)
flag=true;
break;
if(!flag)
else
TERMINAL WINDOW
PG-1 pg. 17
PG-1 pg. 18
QUESTION 8
Q.8 Write a program to find the greatest and the smallest of three input numbers and also
print the sum of these greatest and the smallest number found.
Coding:
int num=3;
boolean flag=false;
for(int i=2;i<=num/2;++i)
if(num% i==0)
flag=true;
break;
if(!flag)
else
TERMINAL WINDOW
PG-1 pg. 19
QUESTION 9
PG-1 pg. 20
Write a program to find the square and cube of n natural numbers (n is entered by the user)
Coding:
import java.util.*;
int num;
System.out.print("Enter an integer:");
num=sc.nextInt();
TERMINAL WINDOW
QUESTION 10
PG-1 pg. 21
Write a program in Java to print all the Pythagorean triplets from 1 to 1000.
(Pythagorean triplets are the numbers that satisfy Pythagoras theorem eg. 52 + 122 =132 so
5,12 and 13 are Pythagorean triplet)
Coding:
import java.io.*;
import java.util.*;
class question10
// triplet: a^2+b^2=c^2
int a,b,c=0;
int m=2;
while (c<limit)
// Evaluate and print triplets using the relation between a,b and c
a=m*m-n*n;
b=2*m*n;
c=m*m+n*n;
if (c<limit)
break;
PG-1 pg. 22
m++;
// Driver code
int limit=1000;
pythagoreanTriplets(limit);
TERMINAL WINDOW
PG-1 pg. 23
PG-1 pg. 24
THANK
YOU
PG-1 pg. 25