You are on page 1of 25

PROJECT

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

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 .
2 Q.2 Write a program to input 16.5.21 9-10
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

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%

Write a program to input the


name and the amount of
ticket for the
customer.Calculate the
discount and net amount to
be paid.

4 Q.4 Write a java program to 17.5.21 14


print all the 26 letters of
English alphabet in Upper
case using do while loop.

5 Q.5 Write a program in 23.5.21 15


JAVA to print the
multiplication table of 17 till
15.
6 Q.6 Write a program in Java 19.5.21 16
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.
7 Q.7 Write a program in Java 24.5.21 18-19
to check whether the
number entered by the user
is a prime number or not.
8 20.5.21 19-20
Q.8 Write a program to find
the greatest and the
smallest of three input
numbers and also print the

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:

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

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:

public class question1

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter Name: ");

String name = in.nextLine();

System.out.print("Enter age: ");

int age = in.nextInt();

System.out.println("Enter your gender:");

char gen=in.next().charAt(0);

if(gen=='f'||gen=='F')

System.out.println("WRONG CATEGORY");

PG-1 pg. 6
else

System.out.print("Enter taxable income: ");

double ti = in.nextDouble();

double tax = 0.0;

if (age > 65) {

System.out.print("Wrong Category");

else {

if (ti <= 160000)

tax = 0;

else if (ti < 500000)

tax = (ti - 160000) * 10 / 100;

else if (ti <= 1000000)

tax = 34000 + ((ti - 500000) * 20 / 100);

else

tax = 94000 + ((ti - 1000000) * 30 / 100);

System.out.println("Name: " + name);

System.out.println("Tax Payable: " + tax);

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;

public class question2

public static void main(String args[])

Scanner sc = new Scanner(System.in);

PG-1 pg. 8
System.out.print("Input a number : ");

int num = sc.nextInt();

int ans = 0;

for(int i=0; i<num; i++)

if(i*(i+1) == num)

ans = 1;

break;

if(ans == 1)

System.out.println("Pronic Number.");

else

System.out.println("Not a Pronic Number.");

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;

public class question3

public static void main(String[] args)

String name[];

double amount[];

double discount=0,net=0;

int i=0;

Scanner sc = new Scanner(System.in);

name=new String[15];

amount=new double[15];

for(i=0;i<1;i++)

System.out.println("Customer:"+(i+1));

System.out.print("Enter name: ");

name[i] = sc.nextLine();

System.out.print("Enter ticket amount: ");

amount[i] = sc.nextDouble();

sc.nextLine();

PG-1 pg. 11
}

System.out.println("Sl. No.\t Name \t Charges \t Discount \t Net Amount");

for(i=0;i<1;i++)

if(amount[i] > 70000)

discount = 0.18*amount[i];

else if(amount[i] >= 55001 && amount[i] <= 70000)

discount = 0.16*amount[i];

else if(amount[i] >= 35001 && amount[i] <= 55000)

discount = 0.12*amount[i];

else if (amount[i] >= 25001 && amount[i] <= 35000)

discount = 0.10*amount[i];

else if (amount[i] <= 25000)

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

public static void main(String args[])

char c='A';

do

System.out.println(c);

c++;

while (c<='Z');//for uppercase use 'A' and 'Z'

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

public static void main(String args[])

int a=1;

while(a<=15)

System.out.println("17*"+ a +"="+ 17*a);

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;

public class question6

public static void main(String args[])

Scanner reader=new

Scanner(System.in);

System.out.print("ENTER A NUMBER:");

int num=reader.nextInt();

if(num%2==0)

System.out.println(num + " IS EVEN");

else

System.out.println(num + " IS ODD");

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:

public class question7

PG-1 pg. 16
{

public static void main(String args[])

int num=3;

boolean flag=false;

for(int i=2;i<=num/2;++i)

//conditional for nonprime number

if(num% i==0)

flag=true;

break;

if(!flag)

System.out.println(num +"is a prime number.");

else

System.out.println(num +"is not a prime number.");

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:

public class question7

public static void main(String args[])

int num=3;

boolean flag=false;

for(int i=2;i<=num/2;++i)

//conditional for nonprime number

if(num% i==0)

flag=true;

break;

if(!flag)

System.out.println(num +"is a prime number.");

else

System.out.println(num +"is not a prime number.");

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:

//Java Program to find square.cube

import java.util.*;

public class question9

public static void main(String args[])

Scanner sc=new Scanner(System.in);

int num;

System.out.print("Enter an integer:");

num=sc.nextInt();

System.out.println("Cube of " + num + " is: " + Math.pow(num,3));

System.out.println("Square of " + num + " is: " + Math.pow(num,2));

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:

// Java program to generate pythagorean triplets

import java.io.*;

import java.util.*;

class question10

// Function to generate pythagoran triplets

static void pythagoreanTriplets(int limit)

// triplet: a^2+b^2=c^2

int a,b,c=0;

// loop from 2 to max_limitit

int m=2;

// Limiting c would limit

// all a,b and c

while (c<limit)

//now loop on j from 1 to i-1

for (int n=1; n<m; ++n)

// 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;

System.out.println(a+ " " + b + " " + c);

PG-1 pg. 22
m++;

// Driver code

public static void main(String args[])

int limit=1000;

pythagoreanTriplets(limit);

TERMINAL WINDOW

PG-1 pg. 23
PG-1 pg. 24
THANK
YOU

PG-1 pg. 25

You might also like