0% found this document useful (0 votes)
8 views8 pages

Class 8 Worksheet Java Python Worksheet

The document provides a comprehensive list of programming exercises focused on mathematical operations and logical conditions. It includes tasks such as calculating sums, areas, and discounts, as well as implementing conditional statements and loops. The exercises are designed to enhance programming skills in various scenarios, including geometry, finance, and data manipulation.

Uploaded by

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

Class 8 Worksheet Java Python Worksheet

The document provides a comprehensive list of programming exercises focused on mathematical operations and logical conditions. It includes tasks such as calculating sums, areas, and discounts, as well as implementing conditional statements and loops. The exercises are designed to enhance programming skills in various scenarios, including geometry, finance, and data manipulation.

Uploaded by

Twinkle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
List of Programs to Practice Simple programs using mathematical operators 1. Write a program to accept two numbers find and display the sum of two numbers. 2. Write a program to accept two sides of a rectangle, Compute and display the area and the perimeter’ of the rectangle. 3. Write @ program to accept the radius of a circle. Compute and display the area and the circumference of the circle. 4, Write a program to accept the temperature. in Celsius. Compute and display the equivalent temperature in Fahrenheit. [ f=9*c/5+32.] Write a program to accept two sides ofa rectangle. Compute and display the length of the diagonal of the rectangle. 6. Write a program to accept the Principal, rate of interest and time. Compute and display the Amount, the Compound Interest and Simple Interest. 7. Write a program to accept three numbers. Compute and display the sum and the average of the three numbers. 8. A Computer manufacturing’ Company announces a special offer to their customer on purchasing Laptops and the Printers accordingly: On Laptop: Discount - 15% On Printers: (Discount - 10% Write a program to)accept the purchase price of Laptop and-Printer, calculate the discount and display thenet-amount the customer will pay on his purchase. In an election, two candidates A and B contested. Agot 60% of the votes. Write a program to accept the total number of votes and calculate the number of votes each candidate got and display the result. 10.Write-a program to accept the length of the perpendicular and base of a right angled. triangle. Calculate and display the hypotenuse and/area of the triangle. 11. Write a program to accept the basic pay-of an employee, Compute and employee based on following allowances and deductions: play the net pay of the Deamess Allowance 25% of Basic Pay House Rent Allowance 15% of Basic Pay Provident Fund 10% of Basic Pay Gross Pay = Basic Pay + Deamess Allowance + House Rent Allowance Net Pay = Gross Pay = Provident Fund 12. Write a program to accept three sides of a triangle. Compute the aréa of the triangle using Hero's formula i.e. area of.a triangle = vs(s-a)(S-b)s-c) where s=(.a+ b+ c)/2. Display the result. 13. Write a program to\calculate the value of x and y if x= a? +.b3and y = b? - a? where value of ‘a’ and ‘b’ is to be:given as input. 14, Write a program to accept the purchase price of a TV and/calculate the selling prices of TV which will give the shop keeper 15% profit and a loss of 5%. Display the selling prices in both the cases. 15. Write a program to accept the present population of a country and calculate the population ‘after 7 years if the growth rate is 7% per year. Display the population at the end of 7° year. 16. Write a program to accept a number of seconds as input and convert the number to the corresponding number of hours, minutes and seconds and display it. 17. WAP to calculate the distance travelled by a person in the hours given as input, taking average speed of travelling as 40Km per hour. 18. Write a program to input the purchase price of a TV and display the price customer will pay. The shopkeeper allows 10% discount on purchase price and charges tax 12.5% on the net amount. 19. Write a program to input the input product code, price of product, quantity of product. Calculate the total cost and discount 12% on total cost. Find the net price to\be paid for the product. Print all the data as output. 20. Write a program to swap the value stored in ni and n2. Print the value before and after they are interchanged. 21, Write @ program (to input the total monthly income. Find théitotal income, tax discount 20% of the total income,. Find total taxable income and sales taxat 15% of the taxable income. Display the net income. indition: mi 1, Write a program to accept any three numbers. Display the greatest among them. 2, Write-a program to accept any three numbers. and display the smallest number among_them using nested if statement. 3, Write a program to accept any number ‘and Check if the number is odd or even. 4. Write a program to accept three numbers. and check whether they are Pythagorean Triplet or not. The program must display message accordingly. 5. Write a program to accept any year and check if it is aleap year number or not. 6. WAP to input any year from 1000 to 2005 and print the number of days in that year. 7. WAP to accept three sides of a triangle and check whether the triangle is possible or not. 8. Write’a program to accept the sides of a triangle and display whether it is an Equilateral or Isosceles or a scalene triangle. 9... Write a program to accept the cost price arid the selling price of an article and calculate either profit percent or loss percent. 10. Write a program to accept any three digits number and count the numbers of odd digits present in it. If odd digits are not found display appropriate message. 11, Write a program to accept a three digit number and form the biggest number using the digits of the number and display the new number. 12. A bank offers the following denominations of notes: *500, * 100, ° 50,° 20, 10,°5,°2,°1 Write a program to accept the amount of money to be withdrawn and'find out the number of notes of each denomination 16, bé given by the bank. 13. Write a program-to accept any number below 10000 and display’the amount to be added to it to make the biggest number having same number of digits as of the number given as input. Use if else ladder‘to-solve the problem. 14. Write a_program to accept the class in which a student is taking admission and display the tuition fees he would have to pay per month using the table below: CLASS Tuition Fee per month 1to3 Rs. 500/- 4to 7 Rs. 600/- 8 to 10 Rs. 950-/. 15. Write a program to calculate the library) fine for the books returned late as per the following rules of the library: up to 5 day Rs. 0.40 per day Next 5 days Rs. 0.65 per day Above 10 days Rs. 0.80 per day 16. Write a program to check if a three digit number is a Armstrong number or not 17. 1n a firm employee is paid as follows: S.No. Basic Salary DA HRA 1. Less.than\2000 10% 5% 2 Greater than equal to 2000 but less than 4000 25% 15% 3. Greater than equal to 4000 but less than 8000 30% 25% greater than 8000 40% 30% Write a program to accept the Basic salary and calculate the gross salary and net salary after making following deductions: 1. P.F..at 10% of Basic Salary 2, LTyat 2% of Basic Salary Display Gross Salary and Net Salary. 18. WAP to accept value of a, b, cand compute the roots and display following results. If b? - 4ac results a positive answer display “REAL AND DISTINCT ROOTS” If b? - 4ac results a negative answer display “IMAGINARY ROOTS” If b? - 4ac results 0 display "REAL AND EQUAL ROOTS” 19. Write a java program to find the solution of any pair of linear simultaneous equation as follows: ax + by sc px +h gy, The program. shoul (i) accept values of a, b, p,q and r. (ii) Use x = (cq ~ br)/ aq - bp) and y = (ar ~ cp)/aq - bp) (iil) print "No finite solution” if aq ~bp-= 0. 20,During sale a shop offers discount on the total purchases made by any customer. If the/purchase is less than Rs. 1000.00 the rate of discount is only 5%, for purchase from Rs. 1000.00 to 4999.00 rate of discount is 10% and:purchase of Rs.5000.00 and above the rate of discount is at. 22. 23. 24. 2. 26. 27. 2B. 29. 30. 15%, Write @ program to input the purchase amount and find the discount and amount to paid by the customer. Write a program to calculate the Telephone bill according to the following rules: i. Minimum of Rs.250.00 is charged as tent. First 80 calls FREE Next 60 call @ Rs.0.60 Next 60 call @ Rs.0.50 v. Above 200 call @ Rs.0.40 Write a program to calculate electricity bill for the number of units consumed given as input, following the rules given below Minimum Meter rent charges ——_—Rs.100.00 Up to 250 units Rs.0.80 per unit Above 250 units Rs.1.50 per unit . Given three numbers A, B and C, Write a program to write their value in an ascending order. For Example, if A=12, B=10 and 5, your program should print out as under Smallest Number 10 Next higher number, 2 Highest Number 15 In an office there are three grades of employees, namely, A, B and C. Write a program to accept the Pay and the Grade and calculate bonus obtained by, them as per following rules: For arade A Bonus = 10% of Pay For grade B Bonus = 12% of Pay, subject to maximum of Rs.2000.00 For grade C Pay up to Rs.5000.00 5% of Pay Pay above Rs.5000 to/Rs.8000 7% of Pay Pay above Rs. 8000.00 10% of Pay Write a program in Java to calculate the income tax paid by Mr. Kartar Singh to the Govt. of India on his annual income as per the slab given below: Slab Income Tax Up to Rs. 50,000 No Tax Rs,50,001 to Rs.60,000 10% of the amount exceeding Rs.50,000/- Rs.60,001 to Rs.1,50,000 Rs.1000 + 20% of the amount exceeding Rs.60,000/- Rs.1,50,000 and above Rs.19,000 + 30% of the amount exceeding Rs.1,50,000/- Take annual salary as input and display the income tax to be paid by him, Write a program to compute charges for sending parcels when the charges are as follows: For the first 1000gms_Rs.15.00 and for additional weight of every 500gms or fraction thereof Rs.8.00. Accept the total weight of the parcel and display the charges A security agency pays to their staff as per the tariff given below: Hours Rate For first 48 hours in a week Rs. K per hour For next. 8-hours in a week Rs.1.25K per hour For further hours in a week Rs.1.50K per hour Write-a program in Java to calculate the weekly wages of the staff taking number of hours~and rate per hour as inputs. Write a program that displays the number of notes in each of the denominations i.e. number of 1000 rupees not, number of 500 rupees notes, number of 100 rupees notes Till number of 5 rupees note, for a given amount. DTDC courier service charges for the transportation of any parcel within eastem zone as follows: Up to 100gms. + Rs.30.00 For each additional S0gms.or part thereof: Rs.10.00 Write a program to calculate the charges of a parcel taking the weight of the parcel as an input. ‘ABC Limited revised its rate of interest for public deposits as follows: YEARS CUMULATIVE INTEREST ANNUAL INCOME SCHEME Scheme (p.2.) (Compounded Annually) 1 11% 2 11.5% 3 12.5% 12% 4 12.5% 12% 5 12.5% 12% Deposit.under the cumulative scheme is accepted or a period of 3 to 5 years only. Write a program in Java ti find the: {i)-amount (A) due for sum (P) invested under the cumulative option scheme, by using the formula A=P* [1 + (0.01 * rT (i) interest, (1) for each year under the annual interest ‘scheme, using the formula 1=0.01*P¥*r*t. 31. Write @ program to accept length and breadth of a\rectangle. Calculate and display the area, perimeter or diagonal of the rectangle as per user's choice. 32. Write an menu driven program to find the area of an Equilateral triangle, an isosceles triangle and a scalene triangle as per User's choice. 1, Equilateral Triangle =V3/4 8 s?, s = side of an equilateral triangle 2. Isosceles Triangle = % * b * V4a2> BZ, a = equal sides of a triangle, b = base 3. Scalene triangle = vs * vs(s-a)(S=b)s-c) where s=( a +b + c)/2, a, b, c are three sides of a triangle. 33. Write a menu driven program to find the sum, difference and product of two numbers. Perform the tasks accordingly. Enter ‘+’ to find sum, '-’ to find the difference and “*’ to find the product of two numbers. 34, Using switch case statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice an appropriate error message should be displayed, [C = 5.0/9.0 (F - 32) and F = 1.8* c + 32} 35, Write a menu driven program to calculate the following: 1. Area of acircle/= PI* 1? (PI=22.0/7.0) 2. Area of.asquare = side * side 3. Area of a'rectangle = length * breadth. 36. Write a menu driven program to calculate the following: 1. Volume of a cube = side * side * side 2OVolume of a sphere = 4.0/3.0 * PI * radius * radius * radius (PI=: 3, Volume of a Cuboid = length * breadth * height. 37.Write a menu driven program to perform either of the following conversions depending on the user's choice: (KM to CM (ii) Hours to Minutes (il)Centigrade to Fahrenheit 2.0/7.0) 1, Write a program to find the sum of the even & odd numbers from 1 to 100. 2. Write a program to accept 10 different numbers and display the greatest and the smallest of the numbers. 3. Write a program ‘to print first 50 numbers of Fibonacci series, 4, Write a program’ to print the mathematical table of any given number. 5, The production (P) of crude oll of a country in millions of barrels may be estimated by the following set of equations, where t represents the time in years. P=Se 3.0 Sts 3, P= 14 4 (t- 5/2), fort >3, Write'@ program in java to find the production for every year from t = 1 to 10 and print it, 6. _Write'a program to print the number of leap year till the current year. Leap year condition is [if(y%400==0 || y%100!=0 && y%4==0)]. 7. Write a program to display the value of ‘x’-and ‘fx’ if fx = (x2+1)/(x2_- 1) and x ranges from 0 to 2.5 in step of 0.5. Take the value of x= 0 when x = 1.0. 8 The population of a country at the end.of the year can be found out by multiplying. the population (P) at the beginning of the year by (1 + X/100) where X is the growth rate of the Population. Taking as input the population (P) at the beginning of the year 1999 and the growth rate (X), write a program to find the population at the beginning of each year from 2000 to 2014. 9. Write a program to calculate and print the value of Y where Y equals to: Y = (n6 + n# +n? + 10)/(n5 +n? +n) for n ranging front10 to 100 in step 5. 10. Write a program to calculate and print the factorial value of any single digit number. 11. Write a program to print all the Pythagorean triplets between and 50. 12. Write a progrant-to accept a number and find the minimum. prime digit of the number. 13. Write a program’ to compute and print all the prime numbers’ between 100 and 500. 14. Write a program to display all the set of 5 consecutive composite numbers between 1 and 100. 15. Write a-program to calculate the sum of all 3 digit prime number. 16. Write a.program to accept a number and check if itis Armstrong prime or not. 17. Write-a program to display all the Armstrong number between 100 and 999 in ascending as well as in descending order. 18. Write a program to calculate and print the HCF and LCM of any two numbers using for loop. 19. Write a program to accept two numbers “and find their LCM without finding the HCF. 20. Write a program to compute the following of any given number: 1. All the factors of the number 2, All the even factors of the number 3. All the odd factors of the number 4. All the prime factors of the number 21. Write-a program to find out the integer between 1 and 10000 that has the largest number of divisors. Print out the maximum number of divisors and an integer that has that many. divisors, 22: Write a program to check if the number is perfect or not. 23,Write a program to find and print all the perfect number between 1 and 100. [Perfect number is the number, which equal to the sum ofits factor other than the number itself. For example 6=14243] 24, Write a program to check and list all the special number between 1 and 1000. 25. Write a program to display all the prime Fibonacci series between 1 an 1000. 26. Write a program to display following output 1294511111 12345 ea) 55555 99999 ROGAN AR PERI be Gr 54444 97777 1234533333) 34567 9 10 1112 54333 97555 1234544444." 45678 13 14 15 16 54322 97533 1234555555) 56789 17 18 19 20 54321 97531 27. Write a program. to display following output: 1 1 123 1 1234567 55555 12 22 1234 ©1222 12345 4444 123 333 123 13 23°33 123 333 1234 4444 12 142434441 22 12345 55555 1 1525 35.45 55 1 1 12345 151413 12 11 13579 31 6789 109 8 7 35791 531 10 1112 654 57913 7531 13:14 32 79135 97531 15 1 97531 28. Write a program to display following output: 1 1 1 54321 12 1 12 24 5432 126 12 123 369 543 12624 112/123 1234 48 12 16 54 126 24120(1 12 123 1234 12345 5 1015 20 25) 5 29. Write a program to display following output: 1 5 1 1 i 24 45 22 123 121 apm 345 333 12345 123.211 4324 2345 4444 1234567 121 5432112345 55555 1 30,Write a program to display following output: U0 01 Mf dd = 222) sig Batis Adlon 0001001010 22213 <12221 12221 01010 0010010101 22133((12221 12321 00100 W000 O010 =—2isss 12220 iaized O00 1000010101 13333 41111 41111 10001 1 10101 10000 ****§ 10 1010 01000 +ee ge 101 101 Qo1a0 +H g ee 1010 10. 00010 *g*** 10101 t ooooL geese 31, Write a program to display following output: 1 1 “567898765 97531 250 1 1 1234554321 232 124 4567654 7531 16 13 4 ©1234 4321 34543 12321 34543-53109 135 «912332 4567654 1234321 23200 3041357 16 12 24 567898765 123454321 1 2 01 13579251 1 32,4 22 333 4444 55555 33. 25 10 17 26 ..... 10 34) 1:12 123 1234 12345 35. 36. 37. 38. 10. il. vatanaain 11111 0 3.8.15 24 35 48 63 80 99 [2011] 1.3715 31 63 127 255 511 1023 Write a program to calculate the sum of following series: Le SH 1F2 + 263 + B44 + APS on 1920). 2.0 S=1+ (142) + (14243) + (1424344) + H1AZ+ aes tn) 3 Pad * (142) * (14243) * (142344) FU (LHD. tn) 4 SH141/3 M/S $1/7 4004 Yin 5 SH143454+74 uN 6 SH H-243-445-64 coe HM 7 S=2+4+64+8+....40 8B SH=2+S $10 $17 $26 Fenn dO term 9 S = 12344 + 2344S + 3FA*5*6 +... + 7*B*O1O 10, SH12+ RH Has... 425% Ml, S=14+4494 16425 +....... +n! terms 12, S = 1/1 4(142)/21 + (14243)/31 + (14243 44)/4\ 1A- 13. 14347415 +31 + -----+nth terms 14. S = 0,540.05 40.005 + 0.0005 + - -+8th term. 15. SSR + 2/21 + 08/31 + xt/41 + ~ == -4O0/n. 16. CS 1 + 1/(142) + 1/(14243) + 1/(1424944) + ~~~ - 41/(142434 - -- - tn) 17S = 149/2402/3403/44- -+a""i/n Where a and n is given as input. 1B.~ S = 1+a/214a2/31 443/41 +- -#a°/11! Where a is given as input. 19. S=1- a/2) + a2/3!- a /41+- +a19/20! Where ais given as input. 20. S = %H1/8+1/12+ ..... up ton terms. 21 S = 1/1! - 2/2! + 3/3! ~ 4/41 4..3...up to n terms. 22, S$ =x2/2! + 8/4! + 8/8) 2, Up ton terms, 33 Sate 2e3eaie eee ant 24, S = (24 * 1) + (21 *2) + (18 *3) + (15*4) +........ upton terms. 25, S=il 42143! +4l+. oe on eae: 26. S=h+2/3+%4+4/5+....... .ton terms 27. S=9+994+848947479+ ton terms Programs using while and do Loop Statements Write a program to print the 52"! term of the Fibonaccl series. Write a program to\print the Fibonacci series below 750. Write a program to accept a number and check whether the number is present in the Fibonacci series or not, Write a program to input any number and out following tesults: i, Print the digits in reverse order. ili. Product of the individual digits ii, Sumof the individual digits iv. Arrange the digits in descending and ascending order v. Find-the Smallest Digit vi. Find the:biggest digit Write a program to accept a number and display the frequency of each digit present in the number. Write a program to input any five digit number and form the biggest number using the digits of the number given as input. [Example: Input number - 67539 program output should. be 97653] Write a program to input any five digit number and form the biggest number using the digits of the number given as input. [Example: Input number - 67539 program output should be 35679 OR Input Number 50143 Output should be 10345] Write a program to check ff the given number is a palindrome number or not. Write a program to input any number and generate a palindrome number using the number given as input Write a program toaccept a number and find out the sum of the'squares of the digits of the number. Write a program in-java to calculate the fare for passengers travelling on a computerized bus. As a passenger enters the bus, the computer displays “What distance will you travel?” On entering the distance, the fare is displayed on the screen according to the following table: Distance Fare Up to 15 KM Rs. 5.00 Up to 25 KM Rs. 10.00 Above 25 KM Rs. 15.00 ‘The computer keeps on adding and displaying the total fare after each passenger has entered the distance and the program ends when the distance entered as "0". It then displays the total number of passengers who entered the bus and the total fare collected. 12. Write a program to display first 50 prime numbers froma given number. 13.A prime_number is said to be "Twisted Prime”, if the new number obtained after reversing the digits is also a prime number. Write a program to accept a number and check whether the number is “Twisted Prime” or not. 14. Write a program to accept any number and find the sum of its prime digits. 15. Write a program to accept a number and check if it is prime number or not. 16,Write a program to accept a number and check if it is automorphic number or not. 17. Write a program to display all the automorphic numbers between 1 and 10000. 18. Write a program to calculate and print the HCF and LCM of any two numbers using division method, 19. Write a program to check if the number Is special or not. [A number is equal to the sum of the factorial of each digit] [2011] 20. Write a program to input a number and check if the number is magic number or not. 21. Write a program to calculate and print the Binary equivalent of any number. 22. Write a program to\calculate and print the Decimal equivalent of any binary number. 23. Write a program to\convert a given decimal number to octal number. 24, Write a program to calculate and print the Decimal equivalent of any octal number. 25. Write a program to enter a number and checkwhether the;number is neon number or not. A number is said’to be “Neon”, if the sum of the digits of the square of a number is equal to number itself. 26. Write @ program to accept a number and check whether the number is Unique or not. A number is said-to be unique if digits of a number are not repeated. 27. Write’a program to accept a number and check whether the number is a Duck number or\fiot A number is said to be Duck if the digit zero is present in it. 28.Write a program to accept a number and display the new number after removing all zeros. 29. Write a program to accept two numbers M and N consisting of two digits each and use Russian Peasants method to find the product of M and N. The logic of the method is explained below with a example. M N P 17 20 20 8 40 20 4 80 20 2 160 20 1 320 340 0 program stops and displays value of P Pi ing Consti in r ov 1. Write class Students definition with the following members: Data Members: Roll No., Height, Weight. Member Functions/Methods: — get() to accept data.as parameters and initialize data members set ( ) to increase the height in field height based on the parameter. print ( ) toisplay the data. 2. Write class definition with the following members: Data Members: Roll No., Height, Weight. Member Methods: Constructor function to initialize data members by default value of height as 5.5 feet and weight as 50 Kg display ( ) to display the data. 3. Write a java class Time with the following specifications: Data Members Member functions Hour default constructor to initialize time Minutes parameterized constructor: initialize time Seconds show( ) : display time reset ( ) : reset time 4, Write a java cless\Date and define a constructor for the class for the following specification. Data Members Member functions Day (dd) default constructor to initialize date Month (ram) parameterized constructorto initialize date of birth Year (yy) yearPlus( ) : to increase the year of date by 1 display( ) : display date. 5. (Define a class student having the following description: Data members/Instance variable: String name to store'the name of the student.

You might also like