0% found this document useful (0 votes)
159 views2 pages

Basic JAVA Programs Worksheet For Beginners

The document contains 29 Java programming exercises including writing programs to calculate areas of shapes, temperatures conversions, averages, discounts, and commissions. The exercises cover basic programming concepts like input, output, formulas, if-else conditions, and arrays.

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
159 views2 pages

Basic JAVA Programs Worksheet For Beginners

The document contains 29 Java programming exercises including writing programs to calculate areas of shapes, temperatures conversions, averages, discounts, and commissions. The exercises cover basic programming concepts like input, output, formulas, if-else conditions, and arrays.

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

-: Java Programs Exercise:-

1. Write a Java program to enter your name and print it.


2. Write a Java program to enter your name, city, country, age and print them.
3. Write a program to find the area of a rectangle.
(FORMULA: Area of a Rectangle is length x breadth)

4. Write a program to find the area of the triangle.


(FORMULA: Area of triangle is ½ x base x height)

5. Write a program to find the area of the circle.


(FORMULA : Area of a circle is 22/7 x radius2
Here we use variable R as Radius. And C is the variable where we store the result.)

6. Write a program to find the area of the square.


(FORMULA: Area of a square is = Side2 )

7. Write a program to find the volume of the box.


(FORMULA: Area of a box = length x breadth x height.)

8. Write a program to find the circumference of the circle


(FORMULA : circumference = 22/7 x Radius x 2)

9. Write a program to find out the Simple Interest.


(FORMULA : Simple Interest = Principle x Rate x Time / 100)

10. Write a program to find out the simple Interest and the Amount.
(FORMULA : Simple Interest = Principle x Rate x Time / 100)
Amount = Principle + Simple Interest

11. Write a Java program to convert temperature from Fahrenheit to Celsius


Formula (Convert Fahrenheit to Celsius): C = (F – 32) * (5 / 9)

12. Write a Java program to convert temperature from Celsius to Fahrenheit.


Formula(Convert Celsius to Fahrenheit): F = (C * 9/5) + 32

13. Write a program to interchange the value of two numbers without using the third variable.
14. Write a program to calculate the tax for a taxable income of Rs. 4,10,000, if the tax rate is fixed
at 3.2%.
15. Create a program that will generate a bill at McDonald's for four vegetable burgers (@ Rs 45
per vegetable Burger) and three vegetable McPuffs (@ Rs 25 per vegetable McPuff). There is a
special Independence Day discount of Rs 50 on the final bill amount.
16. The average height of 6 boys is 158 cm. When the seventh boy joins the group the average
height changes to 159 cm. Find the height of the seventh boy in the group. Write a program to
store the above data and find and display the height of the seventh boy.
17. Write a program that will compute and display the total bill where a loaf of bread costs Rs. 23.5
and an egg costs Rs. 5.75, where the user enters the loaf of bread and number of eggs to
purchase.
18. An alloy consists of 13 parts of copper, 7 parts of zinc and 5 parts of nickel. What is the
percentage of each alloy in the metal? Write a Java program to store all values and calculate
and display the percentage of each metal.
19. A train covers 120.5 km in 2.3 hours, next 160.75 km in 3.5 hours and the last 140.9 km in 5.5
hours. Write a Java program to store all values and calculate and display average speed.
20. Write a program in Java to input number of days. Find and display number of years, months and days.
21. Write a program to input cost price and selling price. Find and display profit and profit percent or loss or loss
percent. If CP equal to SP display NO PROFIT – NO LOSS.
22. Write a program in Java to input an integer, test and print if the number is Negative or positive.
23. Write a program in Java to input an integer, test and print if the number is EVEN or ODD.
24. Write a program in Java to input two integer numbers. If the first number is greater than the 2nd number,
then print the greater number and it’s double otherwise print the smaller number and its square root.
25. Write a program in Java to input an integer, test and print whether it is perfect square or not. Print
appropriate message.
26. Write a program to input two angles. Find and display it forms a Complementary Angle or not.
27. A wholesaler gives incentives in the form of discounts on the net bill. Write a program to input the net bill
and calculate the discount as follows:
Net Bill in Rupees Discount %
<5000 5%
>=5000 and <10000 10%
>=10000 15%
28. Write a program that will allow the teacher to input the marks obtained in Physics, Chemistry and Biology.
Find and display average marks and grade. Grade is as follows:
AVERAGE GRADE
0 to 50 C
51 to 70 B
71 to 90 A
91 to 100 *

29. A salesman is paid commission on the following basis:


Sales Amount in Rupees Commission %
Up to 10,000 2%
10,001 to 20,000 4%
20,001 to 50,000 8%
More than 50.000 15%

Write a program to input sales amount. Calculate and display the commission% and commission amount
paid to the sales person.

You might also like