0% found this document useful (0 votes)
21 views20 pages

10 Java Programs

The document contains multiple Java classes demonstrating basic programming concepts such as checking even or odd numbers, calculating perimeter, generating multiplication tables, converting Celsius to Fahrenheit, and finding the area of shapes. Each class includes a main method that executes specific tasks and outputs results to the terminal. All classes compiled successfully without syntax errors.

Uploaded by

rishigupta99250
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 views20 pages

10 Java Programs

The document contains multiple Java classes demonstrating basic programming concepts such as checking even or odd numbers, calculating perimeter, generating multiplication tables, converting Celsius to Fahrenheit, and finding the area of shapes. Each class includes a main method that executes specific tasks and outputs results to the terminal. All classes compiled successfully without syntax errors.

Uploaded by

rishigupta99250
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

~ EvenOrOdd • Rishi X

Class Edit Tools Options


EvenOrOdd X

Comprt~ Undo CU! Copy Pam And,_ SouraCOOe.

public class EvenOrOdd


{
public static void main(String[] args)
{
int number= 7;
if (number\ 2 == 0)
{
System.out .println(number + " is even . ");
} else
I<
System.out.println(number + " 1s odd . ");
}
}
}

Class compiled · no syntax errors

P Type here to search m 16•c Haze A -


QI
'a' A..,,
= u ..,
ENG 8:03 PM
IN 2/21/'lD24
,fJ BlueJ: TErminal Window · Rishi X
Options
7 i s odd.

II P Type here to search


,fJ. perimeter - Rishi X

Class Edit Tools Options


perime ter X

Comp!lt: Undo CU! Copy Past• And- SouraCOOe.

public class perimeter


R
public static void main {double 1, double b)
{
System.out.println{ "The entered length is "+l);
System.out.println( "The entered breadth is "+b);
double perimeter= 2*(l+b) ;
System . out.println( "Perimeter of rectangle is= "+perimeter ) ;

~1

A A ..,, ENG 7:05 PM


P Type here to search fJ ~ 16•c Haze 0,- ._,
- = It& .., IN 2/21/lD24
{). Bluel: TEm1inal Window · Rishi □ X
Options
The entered length is 78.0
The entered breadth i s 15 .0
Perimeter of rectangl e is= 186.0

P Type here to search m 16•c Haze A QI i.J @ '3, ENG 7:08 PM


IN 2/21/lll24
~ MultiplicationTable - Rishi □ X

Class Edit Tools Options


MultipllcationTable X

Compil• Lindo Cut Copy Paste Find••• Close Source. Code

public class MultiplicationTable


{
public static void main( int num)
{
System.out.println ( "The entered number is =" +num) ;j
for ( int i= 1; i <= 10; i++)
System.out.println(num + • X " + i + • = " + (num * i ));
}
}
,9, BluE.I: TErminal Window · Rishi (JI X
Options

The entered number is =78


78 X 1 78
78 X 2 156
78 X 3 234
78 X 4 312
78 X 5 390
78 X 6 468
78 X 7 546
78 X 8 624
78 X 9 702
78 X 10 = 780

P Type here to search m 16•c Haze A QI i.J @ '3, ENG


IN
7:30 PM
2/21/lD24
,fJ. CelsiusToFahrcnheit - Rishi X

Class Edit Tools Options


CElslusTofah~heit X

Compil~ Undo

public cl ass CelsiusToFahrenheit


{
public static void main(String[] args)
R
double celsius = 37;
double fahrenheit = (cel sius * 9 / 5) + 32;
System.out.println( "Temperature in Fahrenheit : • + fahrenheit );
}
}

Class compiled· no syntax errors

A - - ' A..,, ENG 7:56 PM


P Type here to search ~ 16°C Haze Q> = It$ .., IN 2/21/'lD24
,9, BlueJ: TErminal Window · Rishi X
Options
Temperature in Fahrenheit: 98.6

II P Type here to search m 16•( Haze A Q> lu @ '31 ~G :Z~/:z


4 ~
,fJ. EvenNumben - Rishi X
Class Edit Tools Options
EvenNumbel:5 X

Compil~ Undo CU! Copy Pam And,_ SouraCOOe.

public class EvenNumbers


{
public static void main(String[] args)
{
for ( int i = 2; i <= 20; i += 2)
I<
System .out . println ( i ) ;
}
}
}

Class compiled - no syntax errors

ENG 8:08 PM
P Type here to search ~ 16°C Haze A QI lu @ '3, IN 2/21/'lD24 ~
,9, Blue.I: Terminal Window · Rishi X
Options
2
4
6
8
10
12
14
16
18
20

II P Type here to search m 16•( Haze A Q> lu @ '31 ~G :;,o;;:;


4
~
,fJ. AreaOfRectangle - RtS~ X

Class Edit Tools Options


AreaOfRedang!e X

Compil'- Undo

public class AreaOf Rectangl e


R
public static void main(St ring[] args)
{
int length = 5;
int width = 3 ;
int area = length* width;
System . out . println ( •·Area of Rectangle: • + area) ;
}
}

A - -' A ..,, ENG 7-.48 PM


P Ty pe here to search ~ 16•c Haze
Q> = u " IN 2/21/lD24
~ Bluel: Terminal Window · Rishi D X

Options
Area of Rectangle: 15

II P Type here to search


-9- MaximumNumber- Rishi X
Class Edit Tools Options
MultipllcatlonTabl.e X NuimumNumber X

Compil~ Undo CU! Copy

public class MaximumNumber


{
public static void main(String[] args)
{
int [] numbers= {5, 10, 15, 3, 20};
int max= numbers(0];
for ( int i= 1; i < numbers.length; i++)
f<
if (numbers[i] > max)
{
max= numbers[i] ;
}
l
System .out . println( "Maximum number: · +max) ;
}
}

Class compiled· no syntax errors

P Type here to search m 16"C Haze A -


Q>
._, A
= u "
..,, ENG 7:39 PM
IN 2/21flD24
,fJ BluE.I: TErminal Window · Rishi X
Options
Maximum number: 20

II P Type here to search m 16•( Haze A Q> lu @ '31 ~G :Z~/:z


4 ~
,fJ. PrintNumben - Rishi X
Class Edit Tools Options
PrintNumbers X

Compil'- Undo CU! Copy PMR And,_ SouraCOOe.

public cl ass PrintNumbers


{
public static void main(String[] args)
{
for ( int i= 1 ; i <= 10; i++)
I<
System.out.println ( i );
}
}
}

Class compiled - no syntax errors

A - - ' A..,, ENG 8:14PM


P Type here to search ~ 16•c Haze
Q> = u " IN 2/21/'lD24
,fJ BlueJ: TErminal Window · Rishi X
Options
1
2
3
4
5
6
7
8
9
10

II P Type here to search m 16•( Haze A Q> ILl @ '31 ~G : ; , ~4 ~


,fJ. SimplclnterBt - Rishi X
Class Edit Tools Options
SimplelntHm X

Compil~ Undo Ctn Copy Pam And,_ Sourer.Code.

public cl ass Simpleinterest


{
public static void main(St ring[] args)
I<
double principal 1000;
double rate= 5;
int time = 2;
double simplelnterest = (principal* rate* time) / 100;
System.out.println( "Simple Interest : • + simpleinterest);
}
}

Class compiled - no syntax errors

A - - ' A ..,, ENG 7:52 PM


P Type here to search ~ 16°C Haze
Q> = u " IN 2/21/'lD24
{) Bluel: TEmlinal Window · Rishi D X

Options
Simple Interes t: 100.0

P Type here to search m 16•c Haze


A -
Q>
- ' A..,,
= It& "
ENG
IN
7:53PM
2/21/lD24
,fJ. AreaOfCircle - Rishi X
Class Edit Tools Options
AreaOfCird, X

Compil~ Undo CU! Copy Pam And,_ SouraCOOe.

public cl ass AreaOf Circl e


{
public static void main(St ring[] args)
{
double radius= 3.5;
~ouble area= Math . PI * radius* radius;
System.out.println( "Area of Circle: • + area);
}
}

Class compiled - no syntax errors

'■' A..,,
P Type here to search ~ 16•c Haze A -
Q> = u ..,
ENG
IN
8:25PM
2/21/'lD24
,9, BlueJ: Terminal Window · Rishi X
Options
Area of Circle: 38.48451000647496

II P Type here to search

You might also like