0% found this document useful (0 votes)
2 views5 pages

Core Java Practical

The document contains Java programming exercises including a program to print a multiplication table, a pattern of asterisks, and a program to calculate the area and perimeter of a circle. Each section provides a solution with code examples and corresponding outputs. The practical exercises are aimed at enhancing understanding of core Java concepts.

Uploaded by

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

Core Java Practical

The document contains Java programming exercises including a program to print a multiplication table, a pattern of asterisks, and a program to calculate the area and perimeter of a circle. Each section provides a solution with code examples and corresponding outputs. The practical exercises are aimed at enhancing understanding of core Java concepts.

Uploaded by

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

CORE JAVA

 JAVA Practicals

A. Write a Java program that takes a number as input


and prints its multiplication table upto 10.
SOL:- import java.util.Scanner;
class Hello
{
public static void main (String[] agrs)
{
int i,n,t;
System.out.println("Enter a number");
Scanner sc= new Scanner (System.in);
n=sc.nextInt();
for(i=1; i<=10;i++)
{
t=n*i;
System.out.println(n+"X"+i+"="+t);
}
}
}
OUTPUT:-

Enter a number

5X1=5

5X2=10

5X3=15

5X4=20

5X5=25

5X6=30

5X7=35

5X8=40

5X9=45

5X10=50

PS C:\Users\WINDOWS\Documents\JAVA>

B.Write a Java program to display the following pattern.


*****
****
***
**
*
SOL:- class A{
public static void main(String [] args){
int i, j;
for(i=5; i>=1; i--)
{
System.out.print(" ");

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


{
System.out.print("*");
}
System.out.println();
}
}

OUTPUT:-

*****

****

***

**

PS C:\Users\WINDOWS\Documents\JAVA>
C. Write a Java program to print the area and perimeter
of a circle.
SOL:- import java.util.Scanner;

class B {
public static void main(String[] args) {
double area,circum,r;
System.out.println("Enter radius");
Scanner sc = new Scanner (System.in);
r=sc.nextDouble();
area=3.14*r*r;
System.out.println(area);
circum=2*3.14*r;
System.out.println(circum);

}
}
OUTPUT:-
Enter radius

78.5

31.400000000000002

PS C:\Users\WINDOWS\Documents\JAVA>

You might also like