0% found this document useful (0 votes)
3 views3 pages

Class 8 Programming Exercise

The document outlines a series of programming exercises for Class 8 students, focusing on basic Java programming concepts. Each exercise requires students to write programs that perform various calculations, such as finding sums, calculating discounts, determining averages, and checking conditions. The exercises cover a wide range of topics, including arithmetic operations, geometry, and data handling.
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)
3 views3 pages

Class 8 Programming Exercise

The document outlines a series of programming exercises for Class 8 students, focusing on basic Java programming concepts. Each exercise requires students to write programs that perform various calculations, such as finding sums, calculating discounts, determining averages, and checking conditions. The exercises cover a wide range of topics, including arithmetic operations, geometry, and data handling.
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

Class 8 programming exercise

1. Write a program to initialize four values in four variables. find sum and product of all.

2. Write a program to initialize 4300 as price and find total discount after applying two successive discounts of 15%
and 30%

3. initialize a,b and c with three values of your choice. find a2 +2ab +b2

4. A shopkeeper buys a TV set for Rs. 32,500 and sells it at a profit of 27%. Apart from this a VAT of 12.7% and
Service Charge is 3.87% is charged. Display total selling price, profit along with vat and service charge.

5. Rohan purchased an old cycle for Rs. 1200 and spend Rs. 250 on repairs, Rs. 350 in colouring and added new
accessories worth Rs. 500. Rohan wants to make a profit of Rs. 1500 on selling the cycle. Find the selling price of the
cycle. Write a java program to store all values and calculate and display the selling price and profit percent of the
cycle.

6. 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.

7. An alloy consists of 13 parts of copper and 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.

8. A salesperson sells goods worth Rs. 4325.00, Rs. 4996.50, Rs. 8935.00 and Rs. 9960.75 in four months. Write a
program to store the above values and calculate and display total and average sales.

9. 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.

10. The angles of a quadrilateral are in the ratio 14 : 6 : 8 : 10. Write a program to store the given ratio. Find and
display each angle of the quadrilateral.

11. Write a program in java to input two numbers. Find and display its sum, difference, product, quotient and
reminder.

12. Write a program that will compute and display total bill where a loaf of bread cost Rs. 23.5 and an egg cost Rs.
5.75, where the user enters the loaf of bread and number of eggs to purchase

13. Write a program to enter Principal, Rate and Time. Calculate and display Simple Interest and Amount.

simple interest= PRT/100

14. Write a program to enter length and breadth of rectangular field. Calculate and display its area, perimeter and
diagonal.

15. Write a program to input roll (int), Name (String), Class(String) Section (char) marks of three subjects(float).
Calculate and display total and average marks.

16. Write a program in java to input number of days. Find and display number of years, months and days.

17. Write a program to input basic pay of an employee. Calculate da, hra,pf, gp and np. Display gp and np. Where
da= 24% of bp, hra = 15% of bp, pf = 8.33 of bp. gp = bp+da+hra, np = gp-pf.

18. Write a program to enter temperature in Fahrenheit and convert it to temperature in Celsius using formula c =
5/9(f-32).

19.
20. Write a program to input radius and height of a cone. Calculate and print the volume of the cone using formula:
v=1/3πr2 h.

21. Write a program that will allow the cashier to input Marked Price of the product. The shop keeper offers
successive discounts as 50% + 75% on the Marked Price. Calculate and display the successive discount and Selling
Price.

22. Write a program to enter distance in km and time in hours. Calculate and display the speed in km/hr and m/sec.

** to convert Km/Hr to m/sec multiply by 5/18

23. Write a program to input values of variable u, t, a respectively. Find and display the value of the following
expression. s= ut + (1/2)at2

24. Write a program to input values of a, b, c and x (Integer Values). Compute and display the value of v, where v
=ax3 +(bx)2 + abc + 2bc

25. 29. The sum of interior angles of polygon = (n -2) x 180, where n = number of sides of the polygon. Write a
program to enter number of sides of a polygon and find and display the sum of the interior angles of a polygon.

26. Write a program in java to input an integer, test and print if the number is POSITIVE, NEGATIVE OR ZERO.

27. 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.

28. Write a program in java to input an integer, test and print if the number is EVEN or ODD.

29. 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.

30. Write a program in java to input an integer, test and print whether it is perfect square or not. Print appropriate
message.

31. Write a program to input two angles. Find and display it forms a Complementary Angle or not.

32. A whole-seller 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 15

>5000 && <=10000 20

>10000 30%

Display Discount %, Discount Amount and Amount Payable.

33. 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 *
34. 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

35. Write a program to enter basic pay and compute dearness allowance (DA) and house rent allowance (HRA) as
following:

Basic Pay in Rupees DA% HRA%

Up to 30,000 58.5 12.0

30,001 to 50,000 65.0 16.5

More than 50,000 73.0 24.8

Calculate da, hra and gp. gp= bp + da + hra. Display Gross Pay.

36. Write a program that will allow the user to input any character from the keyboard. Find and display if it is Upper
Case Alphabet, Lower Case Alphabet or Digit.

37. Write a program to input three numbers. Find and display the maximum number.

38. Write a program to enter units consumed. Find and display total bill as per the following:

Units Consumed Rate per Unit

First 200 Units 4.50

Next 200 Units 5.50

More than 400 Units 6.50

Apart from this every consumer pays a meter rent of Rs. 35

39. Write a program that will allow the user to input marks of three terms. Find and display if the student has passed
or failed. A student is given “PASS” if he scores 50 or above in the average of the three exams or if he scores 63 or
above in the second and third exams.

40. Write a program in java to input an angle. Find and display if it is :- i) Acute Angle ii) Right Angle iii) Obtuse Angle
iv) Straight Angle v) Reflex Angle vi) Complete Angle vii) Invalid Angle (>360 or <=0)

41. Take three sides of a triangle, check if the triangle is possible or not. if possible, check and print if it’s equilateral,
isosceles or scalene triangle

42. WAP to take three angles of a triangle and check if the triangle is possible or not. if possible, check and print if it’s
an acute angled, obtuse angled or right angled triangle.

You might also like