0% found this document useful (0 votes)
21 views

Computer Project

Uploaded by

arshiya4985
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)
21 views

Computer Project

Uploaded by

arshiya4985
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/ 11

Q1 Write a program to print the sum of the inputted numbers.

import java.io.*;

import java.lang.*;

import java.util.*;

class project_1

public static void main (String args [])

int a,b,c=0;

Scanner sc= new Scanner (System.in);

System.out.println("enter two number");

a=sc.nextInt();

b=sc.nextInt();

c=a+b;

System.out.println(+c);

}
Q2 Write a program to print the area of a rectangle, triangle, or circle depending on the
user’s choice.

import java.io.*;

import java.util.*;

import java.lang.*;

class volume

public static void main (String args[])

Scanner sc= new Scanner (System.in);

double t,r,c,h,p=22/7,l,b,ba;

int a;

System.out.println("enter your choice ");

System.out.println("1.AREA OF RECTANGLE");

System.out.println("2.AREA OF TRIANGLE");

System.out.println("3.AREA OF CIRCLE");

a=sc.nextInt();

switch(a)

case 1:

System.out.println("enter the length and breadth ");

l=sc.nextInt();

b=sc.nextInt();

r=l*b;

System.out.println("AREA OF RECTANGLE ="+r);

case 2:

System.out.println("enter the hight and base");


h=sc.nextDouble();

ba=sc.nextDouble();

t=1/2*(ba*h);

System.out.println("AREA OF TRIANGLE ="+t);

case 3 :

System.out.println("enter the radius");

r=sc.nextDouble();

c= p*(r*r);

System.out.println("3.AREA OF CIRCLE "+c);

break;

}
Q3 Write a program to print the angstrom number between 100 and 1000

import java.util.*;

import java.lang.*;

import java.io.*;

class project_3

public static void main(String [] args)

int s=0,r,n,i;

System.out.print("The angstrom numbers are as follows");

for(i=100;i<=1000;i++)

n=i;

while(n>0)

r=n/10;

s=s+(r*r*r);

n=n/10;

if (i==s)

System.out.print(+i+",");

}
Q4 Write a program to print the Fibonacci series till n terms.

import java.lang.*;

import java.util.*;

import java.io.*;

class fibonacci

public static void main(String args [])

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int a = 0;

int b = 1;

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

System.out.println(a);

int c = a + b;

a = b;

b = c;

}
Q5 Write a program to check whether the given number is even or not.

import java.io.*;

import java.lang.*;

import java.util.*;

class project_5

public static void main (String args[])

int num;

Scanner sc = new Scanner(System.in);

System.out.println("Enter a number");

num=sc.nextInt();

if(num%2==0)

System.out.println("even");

else

System.out.println("odd");

}
Q6 Write a program to check whether the given number is a spy number or not.

import java.io.*;

import java.util.*;

import java .lang.*;

class project_5

public static void main(String args[])

int n,q,r,s=0,p=1;

System.out.println("enter a number");

Scanner sc =new Scanner(System.in);

n=sc.nextInt();

while (n>0)

q=n/10;

r=n%10;

s=s+r;

p=p*r;

n=q;

if(p==s)

System.out.println("the given number is a spy number");

else

System.out.println("the given number is not a spy number");

}
}

Q7 Write a program to check whether the given number is pronic or not .


import java.io.*;

import java.util.*;

import java .lang.*;

class project_7

public static void main(String args[])

int n,i,c=1;

System.out.println("enter a number");

Scanner sc =new Scanner(System.in);

n=sc.nextInt();

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

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

c=c+1;

if(c==1)

System.out.println("the given number is a pronic numnber");

else

{ System.out.println("the given number is not a pronic numnber");

}
Q8 Write a program to print bill of electricity board with a meter rent of 500
import java.io.*;
import java.util.*;
import java .lang.*;
class project_8

{ public static void main(String args[])


{
int n,i;
System.out.println("Enter the electricity bill");
Scanner sc =new Scanner(System.in);
n=sc.nextInt();
i=n+500;
System.out.println("The total amount with the rent is"+i);
}
}
Q9 Write a program to print the following pattern.
1

23

456

7 8 9 10

11 12 13 14 15

import java.io.*;

import java.util.*;

import java .lang.*;

public class project_9

public void main (String args [])

int i,j,k=1;

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

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

System.out.print(+k+" ");

k++;

System.out.println();

}
Q Write a program to print the following pattern.
12345
1234
123
12
1
import java.io.*;

import java.util.*;

import java .lang.*;

class project_10

{ public static void main(String args[])

{ int i,j;

for(i=5;i>=1;i=i-1)

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

System.out.print(+j);

if(i==1)

break;

System.out.println();

You might also like