Ashoka Universal School, Sinnar
Academic Session 2024-2025
Java Program
Grade – VIII Subject – Computer
----------------------------------------------------------------------------------------------------------------------------
1. WAP to find the area and circumference of Circle.
public class areaCir
{
public static void main(double r)
{
double pi = 3.14,area, circum;
area = pi*r*r;
Circum =2*3.14 * r;
[Link]("Area of Circle is =" +area);
[Link]("Circumference of Circle is =" +circum);
}
}
2. WAP to find the area and perimeter of Rectangle.
public class areaRect
{
public static void main(double h, double b)
{
double area, peri;
area = h*b;
peri = 2 * (h + b);
[Link]("Perimeter of Rectangel is =" +peri);
[Link]("Area of Rectangel is =" +area);
}
}
3. WAP to find the area of Square.
public class areaSqr
{
public static void main(double s)
{
double area;
area = s*s;
[Link]("Area of Square is =" +area);
}
}
4. WAP to find the average of 4 numbers 76, 65, 87, 46
public class SumAvg
{
public static void main()
{
Int a = 76, b = 65, c=87, d = 46;
double sum, avg ;
sum = a+b+c+d;
avg = sum/4;
[Link](“Average of given numbers is ”+avg);
}
}
5. Find the total bill to be paid if Meena purchased 5 Pencil at the cost of Rs. 5.50 each.
public class Simle
{
public static void main()
{
double c = 5.50, total;
int n = 5;
total = n*c;
[Link](“Total bill to be paid is ”+total);
}
}
6. WAP to divide any two numbers and print the quotient and remainder along with the
numbers
public class Rem_Que
{
public static void main(int a, int b)
{
int rem, quotient;
rem = a % b;
quotient = a/b ;
[Link](“The numbers are : ”+a +”And ” + b);
[Link](“The Quotient is ” + quotient);
[Link](“The Remainder is ” +rem);
}
}
7. WAP to to interchange the value of two numbers without using the third variable.
public class Inter
{
public static void main(int x, int y)
{
[Link]("before swapping numbers: "+x +" "+ y);
x = x+y;
y = x - y;
x= x - y;
[Link]("After swapping numbers: "+x +" "+ y);
}
}
8. WAP to check whether the entered number is even or odd.
public class EvenOdd
{
public static void main(int n)
{
If(n % 2 == 0)
[Link](“This number is Even”);
else
[Link](“This Number is Odd”);
}
}
9. WAP to find whether a person is eligible for voting or not.
public class Voting
{
public static void main(int a)
{
If(a>18)
[Link](“The person is eligible for voting”);
else
[Link](“The person is not eligible for voting”);
}
}
10. WAP to to find largest of three no. using if-else-if ladder.
public class Largest
{
public static void main(int a, int b, int c)
{
if( a >= b && a >= c)
[Link](a + " is the largest number.");
else if (b >= a && b >= c)
[Link](b + " is the largest number.");
else
[Link](c + " is the largest number.");
}
}
11. WAP to print the corresponding days of numbers using if…else…if
eg. If user enters the number 3, it should display 3= WEDNESDAY
(For example : 1 = Monday, ……..7= Sunday)
public class DayOfWeek
{
public static void main(int n)
{
If(n==1)
[Link]("Monday”);
else if(n== 2 )
[Link]("Tuesday”);
else if(n== 3 )
[Link]("Wednesday”);
else if(n== 4 )
[Link]("Thursday”);
else if(n== 5 )
[Link]("Friday”);
else if(n== 6 )
[Link]("Saturday”);
else if(n== 7 )
[Link]("Sunday”);
else
[Link](Invalid Input);
}
}
12. WAP to display the message “you are the winner of our bumper prize”, if customer's
purchase amount is more than or equal to Rs. 50000/- otherwise display “next time shop
for Rs. 50000/- or more to be the winner”.
public class Purchased
{
public static void main(int n)
{
If(n>=50000)
[Link](“You are the winner of our bumper prize”);
else
[Link](“Next time shop for Rs. 50000 or more to be the winner”);
}
}
13. WAP to find the length if area and breadth is given.
public class Rectangle
{
public static void main(double a, double b)
{
double len;
len = a/b;
[Link](“Length of Rectangle is ”+len);
}
}
14. WAP to check the number entered is positive , negative or zero.
public class pos_neg
{
public static void main(int n)
{
If(n==0)
[Link](“Number is Zero”);
else if(n>0)
[Link](“Number is Positive”);
else
[Link](“Number is Negative”);
}
}
15. To display whether the entered character is in uppercase or lowercase.
public class Upp_low
{
public static void main(chat ch)
{
if(ch >= 'A' && ch <= 'Z')
[Link]("Upper Case." );
else
[Link]("Lower Case." );
}
}
16. To display the given remark according to percentage criteria
Percentage Remark
>=90 Excellent
>= 75 and <90 Very Good
>= 55 and <75 Good
<55 needs to work hard
public class Remark
{
public static void main(int p)
{
If(p>=90)
[Link](“Excellent”);
else if(p>=75 && p<75)
[Link](“Very Good”);
else if(p>=55 && p<75)
[Link](“Good”);
else
[Link](“Need to work Hard”);
}
}