P2Cart Logo
A company announces revised Dearness Allowance (DA) and Special Allowance (SA) for their employees.

This Java program calculates the Dearness Allowance (DA) and Special Allowance (SA) for employees based on their basic salary. The program uses if-else conditions to determine the applicable percentage for DA and SA as per the salary ranges, then calculates and displays the amount of both allowances.

Read more
A company announces revised Dearness Allowance (DA) and Special Allowance (SA) for their employees as per the tariff given below:

Basic

Dearness Allowance (DA)

Special Allowance (SA)

Up to Rs. 10,000

10%

5%

Rs. 10,001 to Rs. 20,000

12%

8%

Rs. 20,001 to Rs. 30,000

15%

10%

Rs. 30,001 and above

20%

12%

Read Answer
Write a menu-driven program to input the price and the category ‘0’ (zero) for the ground floor, ‘1’ for the first floor, ‘2’ for the second floor, and ‘3’ for the third floor.

This program calculates the total discount and final price of a flat based on its floor category. The user inputs the price of the flat and the floor category (‘0’ for ground floor, ‘1’ for first floor, ‘2’ for second floor, ‘3’ for third floor), and the program computes the discount on both the price and the development charge. The total discount is then applied to give the final price of the flat after the discount.

Read more
A Promoter cum Developer announces a special bonanza for early booking of the flats for their customers as per the tariff given below:

 Category

Discount on the price

Discount on Development Charge

Ground floor

10%

8%

First floor

2.0%

1.0%

Second floor

5%

5%

Third floor

7.5%

10%

Write a menu-driven program to input the price and the category ‘0’ (zero) for the ground floor, ‘1’ for the first floor, ‘2’ for the second floor, and ‘3’ for the third floor. Calculate and display the total discount and the price of the flat after getting the discount.
Read Answer
Find the volume of a cube, a sphere and a cuboid.

This program is a menu-driven volume calculator that computes the volume of: A cube using the formula V = s³ (where s is the side of the cube). A sphere using the formula V = (4/3) * π * r³ (where r is the radius). A cuboid using the formula V = l * b * h (where l is length, b is breadth, and h is height). The program uses a switch case to allow the user to select which volume to compute. It validates the input and provides an appropriate error message if the user enters an invalid choice.

Read more
     Write a program using a switch case to find the volume of a cube, a sphere and a cuboid. For an incorrect choice, an appropriate error message should be displayed.
a)      Volume of a cube = s*s*s
b)      Volume of a sphere = 4/3*π*r*r*r
c)      Volume of a cuboids = l*b*h

Read Answer
Write a menu-driven program that outputs the results of the following evaluations based on the number entered

This Java program is a menu-driven tool that allows users to perform one of the following mathematical evaluations: Natural logarithm: Computes the natural logarithm (log base e) of a positive number. Absolute value: Finds the absolute value of any number. Square root: Computes the square root of a non-negative number. Random number: Generates a random number between 0 and 1. The program uses a switch statement to handle user choices. Each operation has its specific calculation using Java

Read more
     Write a menu-driven program that outputs the results of the following evaluations based on the number entered by the user:
a)      Natural logarithm of the number
b)      Absolute value of the number
c)      Square root of the number
d)      Random numbers between 0 and 1

Read Answer
Enter ‘c’ to calculate the area of a circle, ‘s’ to calculate the area of a square and ‘r’ to calculate the area of a rectangle.

Description of the Program Input: The program presents a menu to the user, allowing them to choose between calculating the area of a circle, square, or rectangle by entering 'c', 's', or 'r'. Switch Statement: The user's choice is evaluated using a switch statement.

Read more
   Write a menu-driven program to calculate:
a)      Area of a circle = π r2 ( π = 22/7)
b)      Area of a square = side * side
c)      Area of a rectangle = length * breadth

Enter ‘c’ to calculate the area of a circle, ‘s’ to calculate the area of a square and ‘r’ to calculate the area of a rectangle.
Read Answer
Write a menu-driven program to convert a given temperature from Fahrenheit to Celsius and vice versa.

This program provides a menu-driven interface for converting temperatures between Fahrenheit and Celsius. The user can choose to either convert Fahrenheit to Celsius or Celsius to Fahrenheit by entering the respective option. The formulas used for conversion are: Celsius from Fahrenheit: � = 5 9 ( � − 32 ) C= 9 5 ​ (F−32) Fahrenheit from Celsius: � = 1.8 × � + 32 F=1.8×C+32 If the user makes an invalid selection, the program displays an error message prompting the

Read more
Using a 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.
[Hint: C = 5/9 (F – 32) and F = 1.8*C + 32]

Read Answer
Write a menu-driven program to find the sum, difference and product of two numbers.

This program allows the user to perform basic arithmetic operations (sum, difference, product) on two numbers through a menu-driven interface. The user is prompted to choose an operation by entering a specific symbol: ‘+’ to calculate the sum ‘-’ to calculate the difference ‘*’ to calculate the product After selecting an operation, the user inputs two numbers, and the program calculates and displays the result based on the chosen operation. If an invalid option is entered, the program info

Read more
Write a menu-driven program to find the sum, difference and product of two numbers. Perform the tasks accordingly:
Enter ‘+’ to find the sum, ‘-‘ to find the difference and ‘*’ to find the product of two numbers.

Read Answer
Ton to accept any values from 1 to 7 and displays the weekdays corresponding to the number entered from the keyboard.

This Java program uses a switch statement to accept an integer between 1 and 7 from the user and displays the corresponding weekday (Monday to Sunday). If the input is not within this range, an error message is shown. Example: Input: Enter a number (1-7): 3 Output: Wednesday

Read more

Using Switch Case, write a program that allows Ton to accept any values from 1 to 7 and displays the weekdays corresponding to the number entered from the keyboard. 

Read Answer
‘Bank of India’ announces new rates for Term Deposit Schemes for their customers and Senior Citizens.

This Java program calculates the interest earned and the final amount paid for term deposit schemes offered by the Bank of India. The interest rate varies based on the term and whether the customer is a senior citizen or not. It displays the deposited amount, term, age of the customer, interest earned, and the final amount paid.

Read more

‘Bank of India’ announces new rates for Term Deposit Schemes for their customers and Senior Citizens as given below:

Term

Rate of Interest (General)

Rate of Interest (Senior Citizen)

Up to 1 year

7.5%

8.0%

Up to 2 years

8.5%

9.0%

Up to 3 years

9.5%

10.0%

More than 3 years

10.0%

11.0%

The senior citizen applies to those customers, whose age is 60 years or more. Write a program to accept the sum (p) in the term deposit scheme, the age of the customer and the term. The program displays the information in the given format:

Amount Deposited

Term

Age

Interest earned

Amount Paid

Xxx

xxx

Xxx

xxx

xxx

Read Answer
Enter the record of the employees of a company as employee number, age and basic salary.

This Java program calculates the monthly gross salary and net salary of an employee based on their basic salary, with dearness allowance, house rent allowance, provident fund, and employee provident fund. It also checks if the employee is an income tax payer based on their gender and annual gross salary.

Read more
Enter the record of the employees of a company as employee number, age and basic salary. Write a program to calculate the monthly gross salary and net salary of each employee as follows:

Dearness Allowance

Nature

House Rent Allowance

40% of Basic Salary

Provident Fund

12% of Basic Salary

Employee Provident Fund

2% of Basic Salary

Gross Salary = Basic + DA + HRA

Net Salary = Gross Salary – (PF + EPF)

The program further checks whether an employee is an Income Taxpayer or not, as under:

Category

Annual Gross Salary

 

Male (M)

Up to Rs. 1,50,000/-

Income Tax Payer

Female (F)

Up to Rs. 2,00,000/-

Not an Income Taxpayer

Enter ‘M’ or ‘F’ to check the category to decide whether an employee has to pay Income Tax or not. Print employee number, gross salary, net salary and also an ‘Income Tax’ payer or not. Read Answer
St. Xavier School Displays a notice on the school notice board regarding admission to Std. 11th for choosing different streams, according to marks obtained in English, Maths and Science in ICSE Examinations.

This Java program determines the eligibility of a student for different streams (Pure Science, Bio Science, Commerce) in Std. 11th based on their marks in English, Math, and Science.

Read more
St. Xavier School Displays a notice on the school notice board regarding admission to Std. 11th for choosing different streams, according to marks obtained in English, Maths and Science in ICSE Examinations.

Marks obtained in different subject

Stream

English, Math’s and Science>=80%

Pure Science

English and Science>=80%, Math’s>=60%

Bio. Science

English, Math’s and Science>=60%

Commerce

Write a program in Java to accept marks in English, Maths and Science from the console.
Read Answer
Mr. A.P. Singh is a software engineer. He pays annual income tax as per the given table

This Java program calculates the income tax payable based on the given salary slabs. It uses conditional statements to determine the correct tax bracket and calculate the tax accordingly.

Read more
Mr. A.P. Singh is a software engineer. He pays annual income tax as per the given table:

Annual Salary

Rate of Income Tax

Up to Rs. 1,00,000

No Tax

Rs. 1,00,000 to Rs. 1,50,000

10% of the amount exceeding Rs. 1,00,000

Rs. 1,50,000 to Rs. 2,50,000

Rs. 5000+20% of the amount exceeding Rs. 1,50,000

Above Rs. 2,50,000

Rs. 25,000+30% of the amount exceeding Rs. 2,50,000

Write a program in Java to compute the income tax to be paid by him.
Read Answer
A library charges a fine for books returned late as given below

This Java program calculates the fine for late returns in a library. The fine rates vary depending on the number of days late: 40 paisa/day for the first 5 days, 60 paisa/day for the next 5 days, and 80 paisa/day for any days beyond 10.

Read more
A library charges a fine for books returned late as given below:

First five days

40 paisa/day

Six to ten days

60paisa/day

Above ten days

80 paisa/day

Design a program in Java (with relevant supporting material) to calculate the fine assuming that a book is returned N days late.
Read Answer
Write a program to input the code of a particular item, the quantity purchased and 23.12- the rate.

This Java program allows users to input item details, calculates the total purchase price, and determines an appropriate gift based on the total amount spent. The program also provides an option to add more items and concludes with a thank you message.

Read more
Write a program to input the code of a particular item, the quantity purchased and 23.12- the rate. Then ask if any more items are to be purchased! If not, then calculate the total purchase price and print it along with the gift to be presented. The gifts to the customers are given in the following manner:

Amount of Purchase (Rs.)

Gift

100 and above but less than 500

A key ring

500 and above but less than 1000

A leather purse

1000 and above

A pocket calculator

Before ending the program a “thank you” statement should be printed to all the customers. Read Answer
The water department has an annual water conservation tax policy to foster a sense of water conservation.

This Java program computes the annual water conservation tax for a user based on their water consumption in gallons. The tax is calculated according to a tiered tax rate structure.

Read more
The water department has an annual water conservation tax policy to foster a sense of water conservation. The rates are based on the consumer's water consumption. The tax rates are as follows:

Water consumed (in Gallons)

Tax Rate in Rs. /100 gallons

Up to 45

No Tax

More than 45 but 75 or less

475.00

More than 75 but 125 or less

750.00

More than 125 but 200 or less

1225.00

More than 200 but 350 or less

1650.00

More than 350

2000.00

Write a program in Java to compute and display an annual water tax chart based on the input value of water consumption.  Read Answer
For the first 1 kg.: Rs.15.00 For additional weight, for every 500gm. or fraction thereof: Rs.8.00

This Java program calculates the charges for sending a parcel based on its weight. The first 1 kg is charged at Rs. 15, and any additional weight is charged at Rs. 8 for each 500g or fraction thereof.

Read more
Write a program in Java to compute charges for sending parcels when the charges are as follows:
For the first 1 kg.: Rs.15.00
For additional weight, for every 500gm. or fraction thereof: Rs.8.00 

Read Answer
Write a program in Java to find the gross salary of an employee for the following allowances and deductions.

This Java program calculates the gross salary of an employee by applying the Dearness Allowance (25%), House Rent Allowance (15%), and Provident Fund (8.33%) on the basic pay. It then computes the net pay and gross pay accordingly.

Read more
Write a program in Java to find the gross salary of an employee for the following allowances and deductions. Use meaningful variables with a class name employee and basic as input.

Dearness Allowance

25% of Basic Pay

House Rent Allowance

15% of Basic Pay

Provident Fund

8.33% of Basic Pay

Net Pay

Basic Pay + Dearness Allowance+ House Rent Allowance

Gross Pay

Net Pay Provident Fund

Read Answer
The standard form of quadratic equation is given by: ax² + bx + c = 0, and d = b² – 4*a*c,

This Java program determines the nature of the roots of a quadratic equation based on the discriminant value. It takes the coefficients � a, � b, and � c as input and calculates the discriminant to check if the roots are real and unequal, real and equal, or imaginary.

Read more
The standard form of quadratic equation is given by:

ax² + bx + c = 0, and d = b2 – 4*a*c,

is known as discriminant, which determines the nature of the roots of the equation accordingly.

Value of discriminates

Nature

d>0

Roots are real and Unequal

d=0

Roots are real and Equal

d<0

Roots are Imaginary

 Write a program to determine the nature of the roots of a quadratic equation by taking a, b, and c as input.

Read Answer
To accept three sides of a triangle and check whether the triangle is possible or not.

This Java program checks whether a triangle is possible based on the lengths of its three sides. It uses the triangle inequality theorem, which states that the sum of any two sides must be greater than the third side.

Read more
Write a program to accept three sides of a triangle and check whether the triangle is possible or not.
[Hint: The sum of any two sides of a triangle is greater than the third side]

Read Answer
Accept three numbers and check whether they are Pythagorean Triplet or not. The program must display the message accordingly. [Hint: h²=p²+b²]

This Java program accepts three numbers from the user and checks whether they form a Pythagorean Triplet using the condition � 2 = � 2 + � 2 c 2 =a 2 +b 2 , where � c is the largest number. The program displays an appropriate message based on the result.

Read more
Write a program in Java to accept three numbers and check whether they are Pythagorean Triplet or not. The program must display the message accordingly.
[Hint: h²=p²+b²]

Read Answer