KEMBAR78
Practical Programs-Set 1 (Class 10) | PDF | Triangle | Volume
0% found this document useful (0 votes)
57 views5 pages

Practical Programs-Set 1 (Class 10)

The document outlines 20 Java programming tasks for Class 10 students at Hal Gnanajyoti School. Each task includes specific requirements such as input handling, calculations, and conditional statements to solve various problems like triangle classification, discount calculations, and performance evaluation. The tasks also cover concepts like method overloading and class design.

Uploaded by

nuthan.s2119
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)
57 views5 pages

Practical Programs-Set 1 (Class 10)

The document outlines 20 Java programming tasks for Class 10 students at Hal Gnanajyoti School. Each task includes specific requirements such as input handling, calculations, and conditional statements to solve various problems like triangle classification, discount calculations, and performance evaluation. The tasks also cover concepts like method overloading and class design.

Uploaded by

nuthan.s2119
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
You are on page 1/ 5

HAL GNANAJYOTI SCHOOL

CLASS 10
Record Programs (1 to 20)

1) Write a Java Program to input three sides of a triangle, and check whether triangle
is possible or not, if possible, check and display whether it is an Isosceles triangle
or Scalene triangle or Equilateral triangle, otherwise display appropriate error
message. If triangle is not possible display appropriate error message.

2) Write a Java Program to input a month number and display the corresponding
month of the year using switch statement. For example if month number is 3, then
display “March”.

3) A special two-digit number is such that when the sum of its digits is added to the
product of its digits, the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits= 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the
product of its digits. If the value is equal to the number input, output the message
“Special 2-digit number” otherwise; output the message “Not a Special 2-digit
number”.

4) Shasha Travels Pvt. Ltd. gives the following discount to its customers:

Ticket amount Discount

Above Rs. 70000 18%

Rs. 55001 to Rs. 70000 16%

Rs. 35001 to Rs. 55000 12%

Rs. 25001 to Rs. 35000 10%

Less than Rs. 25001 2%

Write a java program to input the name and ticket amount for the customer and
calculate the discount amount and net amount to be paid. Display the output in
the following format:
Name Ticket charges Discount amount Net amount
xxx xxx xxx xxx
5) Write a Java Program to input values for a and b and an option in the range (1 to 3).
Using switch statement, perform the following tasks:
If option is 1, then calculate and display the result of Arithmetic mean.
If option is 2, then calculate and display the result of Geometric mean.
If option is 3, than calculate and display the result of Harmonic mean.
Display appropriate error message if option is less than 1 or more than 3.
Formulas:
(𝑎+𝑏) 𝟐𝒂𝒃
Arithmetic mean= Geometric mean=√𝒂𝒃 Harmonic mean=𝒂+𝒃
2

6) An academy judges the performance of cricketers whether they are “All Rounder”,
“Batsman”, “Fielder” as per the given norms:
If average runs>=40 and average wicket taker>=3 All Rounder

If average runs>=50 Batsman

If average wicket>=4 Bowler

Otherwise Fielder
Average runs=Total Runs/No. of Inning played.
Average Wicket taker=No. of wickets taken/No. of innings played.
Write a Java Program to input No. of runs, Wickets and Innings played and display the
corresponding performance of a cricketer as per the above table.

7) Using Scanner class method, Write a Java Program to input bike number, phone
number, name, and number of days the bike is taken out on rent. Calculate the rental charge
based on the following:
No. of Days Bike taken on rent Rent per day
For first five days ₹500 per day
For next five days ₹400 per day
Rest of the days ₹200 per day

Display the details in the given format:


Bike No Phone No Name No. of days Rental Charge
xxx xxx xxx xxx xxx

8) Write a Java Program to input length and breadth of a rectangle and an option in the
range 1 to 3. Using switch statement, perform the following tasks:
If option is 1, then calculate and display the result of area of rectangle.
If option is 2, then calculate and display the result of perimeter of a rectangle.
If option is 3, then calculate and display the result of diagonal of a rectangle
If option is not matching, then display appropriate error message.
9) Using Scanner class, write a Java Program to input name, sale amount and calculate the
commission as per the conditions:
Sale Amount Commission
Upto ₹5000 5%
More than ₹5000 and upto ₹10000 10%
More than ₹10000 and upto ₹20000 20%
More than ₹20000 30%

Display the employee name, Sale amount and the commission amount.

10) Write a Java Program to input a starting letter of any rainbow colour and display the
corresponding colour name using switch statement.
For Example if the input is V or v, then display the output as Violet.

11) Write a Java Program to display the given pattern

5 4321
4 321
3 21
2 1
1

12) Write a program to display Fibonacci Series for first 10 numbers.

0, 1, 1, 2, 3, 5,………..

13) Write a Java Program to input a number and check whether it is a Niven
Number or not.
[A number is called Niven if the sum of its digits is divisible by the number n
itself]
Example: 126 is a Niven Number because 1+2+6 = 9 and 126 is divisible by 9

14) Write a Java Program to input a number and check whether it is an odd
Palindrome number or not. A number is called odd-palindrome if it is a
palindrome number as well as odd number. A number is called Palindrome when
it is read from left to right or right to left it’s the same number. Examples for odd
Palindromes are 121, 1221, 171,…

15) Write a program to print the sum of the following series up to n terms.

1+4+9+16+25+………..
16) Define a class Admission having the following description:
Data Members/Instance variables:
String Name stores student name.
int marks total marks obtained.
Member functions:
void input () to accept Name and marks.
void Display() Display the student name and the corresponding stream based on
total marks obtained.
Total Marks Stream Offered
300 and above Science
200 and above but less than 300 Commerce
Below 200 but not below 75 Arts
Otherwise Admission not granted

Write a main() method to create an object and call the functions.

17) Define a class BSNL having the following description:-


Data Members:
calls No. of calls made per month.
name Name of the consumer.
charge Stores the amount to be paid.
Member Functions:
void accept( ) To input calls and consumer name.
void calculate( ) Calculate the charges based on the following criteria:

Number of calls Charge


Upto 50 calls No charge(free)
For Next 100 calls ₹ 1 per call
For Next 200 calls 90 paise per call
More than 350 calls 80 paise per call

However, monthly rental charge is Rs.180/- per month for all the consumers for using
Telephones.
void display( ) Display the output in the following format:
Consumer Name Calls Charges
xxx xxx xxx
Write a main() method to create an object and call the functions.
18) Write a class with the name volume using method overloading that computes the
volume of a cube, a sphere and a cuboid.
Formula:
Volume of cube (vc)=s*s
Volume of sphere(vs)=4/3*pi*r*r*r
Volume of cuboid(vcd)=l*b*h

19) Write a class with the name Perimeter using method overloading that computes
the perimeter of a square, a rectangle and a circle.

Formula:
Perimeter of a square=4*s
Perimeter of a rectangle=2*(l+b)
Perimeter of a circle=2*(22/7)*r

20) Design a class to overload a method calculate as follows:

void calculate(int m, char ch) with one integer argument and one character argument, it
checks whether the integer argument is divisible by 7 or not, if ch is ‘s’, otherwise it
checks whether the last digit of the integer argument is 7 or not.

void calculate(int a, int b, char ch) with two integer arguments and one character
argument. It displays the greater of integer arguments if ch is ‘g’ otherwise, it displays
the smaller of integer arguments.

You might also like