Computer Project Solutions

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Program 1 Write a program using Java language to generate the sum of three different

numbers.

class sum
{
public static void main(String[] args)
{
int a=1,b=2,c=3,d;
d=a+b+c;
System.out.println("TOTAL Is"+d);
}
}

Program 2Write a program using Java language to generate the cube of first ten even
numbers using while loop.

Program 3Write a program using Java language to generate the square of a given number.

class square
{
public static void main(String[] args)
{
int a=2,b;
b=a*a;
System.out.println("TOTAL Is"+b);
}
}
Program 4Write a program using Java language to generate the cube of a given number.

class cube
{
public static void main(String[] args)
{
int a=3,b;
b=a*a*a;
System.out.println("TOTAL Is"+b);
}
}

Program 5Write a program using Java language to check whether a given number is even
or odd.

Program 6Write a program using Java language to check whether a given number is
positive,negative or zero.

Program 7Write a program using Java language to generate the table of a given
number up to count ten.
Program 8Write a program using Java language to generate first twenty even numbers.

Program 9Write a program using Java language to generate first ten odd numbers.

Program 10 Write a program using Java language to generate the square of first ten
natural numbers.

Program 11 Write a program using Java language to print the days of the week using
switch case statement.
Note: If input is 2 then output should be Monday.
Program 12 Write a program using Java language to input twenty numbers and
print those numbers that are divisible by 7.

Program 13 Write a program using Java language to input a year in four digit and test
whether it is a leap year or not.

Program 14 Write a program using Java language to display any given word in the
vertical manner. e.g. “GOD”
G
O
D

Program 15 Write a program using Java language to display any given message five
times.

You might also like