P2Cart Logo
Write a program in Java to accept a number and check: a) whether the number is divisible by 2 & 5, b) whether the number is divisible by 2 but not by 5, c) whether the number is divisible by 5 but not by 2

This Java program accepts a number from the user and checks whether the number is divisible by both 2 and 5, by 2 but not 5, or by 5 but not 2. It then displays the result accordingly.

Read more
     Write a program in Java to accept a number and check:
a)      whether the number is divisible by 2 & 5
b)      whether the number is divisible by 2 but not by 5
c)      whether the number is divisible by 5 but not by 2 

   The program must display the message accordingly. 

Read Answer
Accept the cost price and the selling price of an article and calculate either profit percent or loss percent.

This Java program calculates either the profit percentage or the loss percentage based on the cost price and selling price of an article entered by the user.

Read more
Write a program in Java to accept the cost price and the selling price of an article and calculate either profit per cent or loss per cent. 
Read Answer
Accept three angles of a triangle and check whether the triangle is possible or not. If possible then check whether it is an acute-angled, a right-angled or an obtuse-angled triangle and display the message accordingly.

This Java program accepts three angles of a triangle and checks if the triangle is valid. If valid, it determines whether the triangle is acute-angled, right-angled, or obtuse-angled and displays the result accordingly.

Read more
Write a program in Java to accept three angles of a triangle and check whether the triangle is possible or not. If possible then check whether it is an acute-angled, a right-angled or an obtuse-angled triangle and display the message accordingly.
Read Answer
Calculate the value of sin 30° (degree), cos 30° (degree) and tan 30 (degree). Now, display the lowest value of the trigonometrical ratios.

This Java program calculates the trigonometric values of sine, cosine, and tangent for 30 degrees, then determines and displays the lowest value among them.

Read more
Write a program in Java to calculate the value of sin 30° (degree), cos 30° (degree) and tan 30 (degree). Now, display the lowest value of the trigonometrical ratios
Read Answer
Mr. Guha wishes to accumulate 3000 shares of a company.

This Java program calculates how many shares Mr. Guha currently holds based on his annual dividend and how many additional shares he needs to purchase to reach his target of 3000 shares. The program takes the annual dividend as input and computes the results using a formula.

Read more
Mr. Guha wishes to accumulate 3000 shares of a company. However, he already has some shares of that company, Rs.10 (nominal value), which yield a 10% dividend per annum. He received Rs.2000 as a dividend at the end of the year. Write a program in Java to calculate the number of shares he has and how many more shares he needs to purchase to reach his target.

[Hint: No. of share = Annual dividend * 100/ Nominal value * div%]
Read Answer
A shopkeeper offers a 30% discount on purchasing articles whereas the other shopkeeper offers two successive discounts of 20% and 10% for purchasing the same articles.

This Java program compares the discount offers from two shopkeepers on a given article price. It calculates the final prices after applying a 30% discount from the first shopkeeper and two successive discounts of 20% and 10% from the second shopkeeper. The program then displays which offer is more advantageous for the customer.

Read more
A shopkeeper offers a 30% discount on purchasing articles whereas the other shopkeeper offers two successive discounts of 20% and 10% for purchasing the same articles. Write a program in Java to compute and display which is a better offer for a customer. Take the price of an article as an input.
Read Answer
Calculate the amount after three years, taking the sum as an input. A = P (1 + R1/100) (1 + R2/100) (1 + R3/100)

This Java program calculates the total amount after three years of investment with varying compound interest rates: 5% for the first year, 8% for the second year, and 10% for the third year. The program takes the initial sum as input from the user and applies the compound interest formula to compute the final amount.

Read more
A man invests a certain sum of money at 5% compound interest for the first year, 8% for the second year and 10% for the third year. Write a program in Java to calculate the amount after three years, taking the sum as an input.
[Hint: A = P (1 + R1/100) (1 + R2/100) (1 + R3/100)]

Read Answer
A shopkeeper offers a 10% discount on the printed price of a Digital Camera.

This Java program calculates the final amount a customer has to pay for a Digital Camera after applying a 10% discount on the printed price and adding a 6% sales tax on the discounted price. The program prompts the user for the printed price and outputs the discount amount, price after discount, sales tax amount, and total payable amount.

Read more
A shopkeeper offers a 10% discount on the printed price of a Digital Camera. However, a customer has to pay 6% sales tax on the remaining amount. Write a program in Java to calculate the amount to be paid by the customer, taking printed price as an input.
Read Answer
Write a program in Java to calculate: a) the interest for the first year, b) the interest for the second year, c) the amount after three years. Take sum as an input from the user.

Here’s a Java program that calculates the compound interest for each of the first two years and the total amount after three years for an investment made at a compound interest rate of 5% per annum. The user is prompted to input the initial investment amount.

Read more
   Mr. Shyam Lal Agarwal invests a certain sum at 5% per annum compound interest for three years. Write a program in Java to calculate:
a)      the interest for the first year
b)      the interest for the second year
c)      the amount after three years.
Take sum as an input from the user.

Read Answer
Write a Menu-driven program to find the area of an Equilateral triangle, an Isosceles triangle and a Scalene triangle as per the User’s choice. (Incomplete question)

Here's a complete Java program that is menu-driven, allowing the user to choose to calculate the area of an Equilateral triangle, an Isosceles triangle, or a Scalene triangle based on their input. The program prompts the user for the required dimensions based on their choice and calculates the area accordingly.

Read more
Write a Menu-driven program to find the area of an Equilateral triangle, an Isosceles triangle and a Scalene triangle as per the User’s choice. (Incomplete question)
Read Answer
Calculate and display whether they are ‘Complementary Angles’ or ‘Supplementary Angles’ as per the User’s choice

This program accepts two angles from the user and determines whether they are complementary (sum is 90°) or supplementary (sum is 180°) based on the user's choice. The user can select the type of check they want to perform, and the program provides the result accordingly.

Read more

Write a program to accept two angles. Calculate and display whether they are ‘Complementary Angles’ or ‘Supplementary Angles’ as per the User’s choice.

Read Answer
Calculate and display the area, perimeter or diagonal of the rectangle as per the Use’s choice.

The program accepts the length and breadth of the rectangle from the user. The user is prompted to choose between calculating the area, perimeter, or diagonal. Based on the choice, the program calculates and displays the result.

Read more
Write a program to accept the length and breadth of a rectangle. Calculate and display the area, perimeter or diagonal of the rectangle as per the User’s choice.
Read Answer
Write a program in Java to display the colour of the spectrum (VIBGYOR) according to the User’s choice.

This Java program displays a color from the VIBGYOR spectrum based on the user’s input. The user is prompted to choose a number from 1 to 7, and the corresponding color (Violet, Indigo, Blue, Green, Yellow, Orange, Red) is displayed. If the user selects a number outside of the range, an error message is shown. The program uses a switch statement to match the input with the respective color.

Read more
Write a program in Java to display the colour of the spectrum (VIBGYOR) according to the User’s choice.
Read Answer
Atul Transport Company’s charges for the parcels from Delhi to Kolkata or vice versa as per the given tariff

Here is a Java program to calculate the parcel charge for Atul Transport Company based on the given tariff: Explanation: Scanner Class: Used to take input from the user. Input Weight: The program asks the user to enter the weight of the parcel.

Read more
Atul Transport Company’s charges for the parcels from Delhi to Kolkata or vice versa as per the given tariff:

Weight

Charge

Up to 10 kg

Rs. 20/kg

For the next 20 kg

Rs. 10/kg

For the next 20 kg

Rs. 8/kg

More than 50 kg

Rs. 5/kg

 Write a program to calculate the charge for a parcel taking the weight of the parcel as an input.

Read Answer
Jharkhand State Electricity Board (JSEB) charge their consumers according to the units consumed (per month) as per the given tariff

Here is a Java program to calculate the electricity bill based on the given tariff for the Jharkhand State Electricity Board (JSEB): Explanation: Scanner Class: Used to take input from the user. Units Input: The program asks the user to enter the number of units consumed.

Read more
Jharkhand State Electricity Board (JSEB) charge their consumers according to the units consumed (per month) as per the given tariff:

Units Consumed

Charges

Up to 100 units

80 paisa/unit

More than 100 and up to 200 units

Rs.1/unit

More than 200 units

Rs.1.25/unit

In addition to the above, every consumer has to pay Rs. 50 as a Service Charge per month. Write a program to calculate the Electricity Bill.
Read Answer
In an examination, the grades are given according to the marks obtained.

Here's a Java program that takes the marks obtained in an examination and displays the corresponding grade based on the criteria you provided:

Read more
In an examination, the grades are given according to the marks obtained. Write a program in Java to Display the grades accordingly:

Marks

Grades

80% and above

Distinction

60% or more but less than 80%

First Division

45% or more but less than 60%

Second Division

40% or more but less than 45%

Pass

Less than 40%

Promotion not Granted

Read Answer
A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the items purchased

This Java program calculates the final amount a customer has to pay at a cloth showroom after applying a discount based on the total cost of items purchased. The program prompts the user to enter the total cost and determines the applicable discount rate using specific ranges. It then computes the discount amount and the final price to be paid after the discount is applied, displaying all relevant information to the user.

Read more
A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the items purchased:

Total Cost

Discount (in %)

Less than Rs.2,000

5%

Rs.2,001 to Rs.5,000

25%

Rs.5,001 to Rs.10,000

35%

Above Rs.10,000

50%

  Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing of the discount.

Read Answer
Write a program to accept three numbers. If they are unequal then display the greatest number otherwise, display they are equal.

This Java program accepts three numbers from the user. It checks if all three numbers are equal. If they are, it displays a message stating that they are equal. If they are not equal, it calculates and displays the greatest of the three numbers.

Read more
Write a program to accept three numbers. If they are unequal then display the greatest number otherwise, display they are equal.
Read Answer
Accept the sides of a triangle and display whether it is an Equilateral or Isosceles or a Scalene triangle.

This Java program accepts the lengths of the three sides of a triangle from the user and determines its type: Equilateral Triangle: All three sides are equal. Isosceles Triangle: Two sides are equal. Scalene Triangle: All three sides are different.

Read more

Write a program in Java to accept the sides of a triangle and display whether it is an Equilateral or Isosceles or a Scalene triangle.

Read Answer
To find the gross pay of an employee for the following allowances and deductions.

This Java program defines an Employee class that calculates the gross pay of an employee based on the following allowances and deductions: Dearness Allowance (DA): 25% of Basic Pay House Rent Allowance (HRA): 15% of Basic Pay Provident Fund (PF): 8.33% of Basic Pay

Read more
Write a class with the name employee and basic as its data member, to find the gross pay of an employee for the following allowances and deductions. Use meaningful variables.
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