StdIX CH 4&5 Programs
StdIX CH 4&5 Programs
Chapter 4:Operators
Q. Unsolved Java Programming:-
1. Write a program to find and display the value of the given expression:
(x + 3) / 6 - (2x + 5) / 3;
int x = 5;
2. A person is paid ₹350 for each day he works and fined ₹30 for each day he remains absent.
Write a program to calculate and display his monthly income, if he is present for 25 days and
3. Write a program to find and display the percentage difference, when a number is updated
from 7.5 to 7.2
4. The normal temperature of human body is 98.6°F. Write a program to convert the
Hint: c / 5 = f - 32 / 9
double f = 98.6;
5.The angles of a quadrilateral are in the ratio 3:4:5:6. Write a program to find and display all of
int r1 = 3, r2 = 4, r3 = 5, r4 = 6;
double x = 360 / (double)(r1 + r2 + r3 + r4);
double a = r1 * x;
double b = r2 * x;
double c = r3 * x;
double d = r4 * x;
}
Chapter 5: Input in Java
V. Java Programming:
T = 2π√(l/g)
Write a program to calculate the time period of a Simple Pendulum by taking length
Solution
import java.util.Scanner;
double l = in.nextDouble();
System.out.print("Enter g: ");
double g = in.nextDouble();
House Rent Allowance (HRA) 15% of Basic PayProvident Fund (PF) 12.5% of Basic Pay
Solution:
import java.util.Scanner;
double bp = in.nextDouble();
double gp = bp + da + hra;
double np = gp - pf;
3. A shopkeeper offers 10% discount on the printed price of a Digital Camera. However, a customer
has to pay 6% GST 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.
Solution:
import java.util.Scanner;
price += gst;
}
4. A shopkeeper offers 30% discount on purchasing articles whereas the other shopkeeper offers two
successive discounts 20% and 10% for purchasing the same articles. Write a program in Java to
compute and display the discounts.
Solution:
import java.util.Scanner;
Amt2 -= d3;
5. Mr. Agarwal invests 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
Solution:
import java.util.Scanner;
double p = in.nextDouble();
p += interest;
interest = p * 5 * 1 / 100.0;
p += interest;
interest = p * 5 * 1 / 100.0;
}
}