0% found this document useful (0 votes)
15 views14 pages

Computer Project Work 2022-23

Uploaded by

sdrive11406
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views14 pages

Computer Project Work 2022-23

Uploaded by

sdrive11406
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1) A Library charges a fine for books returned late as per the table given below:

1st 5 days - 40 paise per day

6 to 10 days - 65 paise per day

Above 10 days - 80 paise per day

Write a program in JAVA to display the charges.

Solution :

Class fine

Viod main (int n)

Double f=0;

If ( n<=5 )

f=0.40*n;

If ( n>=6 && n<=10)

f= 0.40*n+0.65*(n-5);

If( n>10)

f = 0.40*n+0.65*n+0.80*n (n-10);

System.out.println (“f”);

}
2) Mr. A.P. Singh is a software engineer . He pays annual income tax as follows:

Upto Rs. 100000 ----------no tax

Rs. 100001 to Rs. 150000--------10% tax

Rs. 150001 to RS. 250000--------Rs. 5000 +


20%tax

Above Rs. 250000-----------------Rs. 25000+30%tax

Write a program in JAVA to display the tax.

Solution:

class tax

Void main ( int s )

Double t = 0;

If ( s<=100000)

t=0;

if ( s>=100001 && s<= 150000)

t= 100000/100*10;

if (s>=100001 && s<=150000)

t=5000+250000/100*20;

if (s<250000)

t= 25000+25000/100*30;

System.out.println (“t”);

}
3) Discount table of a cloth shop is as follows:

Less than Rs. 2000 - 5%discount

2001 to 5000 - 25%discount

5001 to 10000 - 35%discount

Above 10000 - 50%discount

Write a program in JAVA to display the discount.

Solution:

class discount

viod main ( int c )

Double t=0;

If (c<2000)

t=5;

if ( c>=2001 && c<=5000)

t=25;

if ( c>=5001 && c<=10000)

t=35;

if ( c>10000)

t=50;

System.out.println(“t”);

}
4) In an exam grades are equal to the marks obtained as in the given table :

80% or above - Distinction

60% above but less than 80% - 1st divisoin

45% above but less than 60% - 2nd division

40% above but less than 45% - Pass

Less than 40% - Fail

Write a program in JAVA to display the grades.

Solution:

class grade

Void main ( int m )

Double g = 0;

If ( m >80)

System.out.println (“Distinction”)

If ( m>=60 && m<80)

System.out.println ( “1st division”)

If ( m>= 45 && m< 60)

System.out.println(“Pass”)

If ( m<40)

System.out.println (“Fail”)

}
}

5) Write a program in bluej to display the sum of following series:-

x/4 + x/8 +x/12


Solution:

class sum

viod main ( int a; int b; int c; int d)

while(d=0);

int d= a+ b+ c;

System.out.println (“d”);

6) Write a program in bluej to check whether a number is Armstrong number or not.

SOLUTION:

class Armstrong

Void main ()

Int i; int n ; int s; int r;

n=m;

for (n!=0; m/=10;n++);

m=n;

for (n!=0; n/=10);

r=n%10

s=r+n
}

if ( s=n)

System.out.println(“ It is Armstrong”)

else

System.out.println (“It is not”)

7) Write a program in bluej to display the following pattern:-

22

333

4444

55555

SOLUTION :

Class loop

Void main ()

Int I; int j;

For ( i=1; i<=5; i++);

For ( j=1; j<= I; j++);


{

System.out.print (i);

System.out.println (“ “ );

8) Write a program in bluej to check whether a number is palindrome number or not:

SOLUTION:

Class palindrome

Void main ( int n )

Int r; int p=0;

While ( n!=0)

r=n%10;

n=n/10;

p=p*10+r;

If( p==n)

System.out.println (“ It is palindrom”)

Else
System.out.println(“ It is not “);

9) Write a program in bluej to display the sum of following series:-

x/21 + x/41 + x/61

Solution :

class sum

viod main ( int a; int b; int c; int d)

while(d=0);

int d= a+ b+ c;

System.out.println (“d”);

10) Write a program in bluej to check whether a number is prime or not :-

Solution:

class PrimeNumber {
void main(String args[]) {
p = new PrimeNumber();
Scanner scan = new Scanner(System.in);
System.out.println(“Enter a number for check in main method:”);
int n = scan.nextInt();
int count = 0;
int number = 0;
for (int i = 2; i <= 9; i++) {
if (n % i == 0) {
System.out.println(" count called when " + i);
count = count + 1;
}
number = number + 1;
System.out.println(" The loop called "+number+" times");
}
if (count == 0) {
System.out.println(n + " is a prime number ");
}

11) Calculate and display the net salary according to the following table:-

NO. BS DA HRA PF

1 <=900 90% 70% 12%

2 9001 – 15000 105% 80% 12%

3 15001-20000 115% 90% 12%

4 >20000 120% 95% 12%

SOLUTION :

class salary

viod main ( int c )

{
Double t=0;

If (c<=900)

t=90;

if ( c>=901 && c<=15000)

t=105;

if ( c>=15001 && c<=20000)

t=115;

if ( c>20000)

t=120;

System.out.println(“t”);

12)Write a program in bluej to display the first 10 even numbers:-

Solution:

Class even

Void main ()

Int i=2;

While (i<=20);

System.out.println(i);
i=i+2

14)Write a program in bluej to check whether a no. is Niven or not:-

Solution:

Class niven

Void main( int n)

Int r; int s=0;

While (n!=0)

r=n%10;

n=n/10;

}
if ( n%s==0)

System.out.println(“It is niven”)

Else

System.out.println( “it is not”)

}
}
15) Write a program in bluej to check whether a no. is neon no. or not:-

Solution:

Class neon

Void main( int n)

Int r; int s=0;intm=n*n;

R=m%10;

N=m/10;

S=s+r;

If ( n==s)

System.out.println( “it is neon”)

Else

System.out.println(“it is not”)

16) Write a program in bluej to check whether a no. is duck no. or not.

Solution:
Class duck

{
viod main( int n)

Int r; int k=0;

While ( n!=0)

R=n%10;

N=n/10;

If ( r==0);

K=k+1;

If ( k>0)

System.out.println( “it is duck”)

Else

System.out.println( “it is not”)

************************************************************************

You might also like