The document contains solved Java programs for various applications related to discounts, interest calculations, employee payroll, and time conversions. Each program includes user input for specific parameters and outputs calculated results based on the provided formulas. Key topics include calculating discounts, compound interest, employee gross/net pay, and time conversions.
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 ratings0% found this document useful (0 votes)
4 views7 pages
Java q1
The document contains solved Java programs for various applications related to discounts, interest calculations, employee payroll, and time conversions. Each program includes user input for specific parameters and outputs calculated results based on the provided formulas. Key topics include calculating discounts, compound interest, employee gross/net pay, and time conversions.
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/ 7
ICSE COMPUTER APPLICATION
CLASS IX
SOLVED PROGRAMS
CHAPTER-INPUT
Program 1. 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.
Take the price of an article as the input.
import java.util.*;
public class Discount
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print{"Enter price ");
double price = in.nextDouble();
double d1 = price * 30 / 100.0;
double amtt = price - d1;
System.out. printin("'30% discount =" + d1);
System.out.printin("Amount after 30% disc
double d2 = price * 20 / 100.0;
double amt2 = price - d2;
double d3 = amt2 * 10 / 100.0;
amt2 =amt2- d3;
System.out.printin("20% discount =" + d2);
System.out.printin("10% discount =" + d3);
System.out.printin("Amount after successive discounts =" + amt2);
}
}
+amtl);Program2. 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.
import java.util.*;
public class CameraPrice
{
public static void main(String args{]) {
Scanner in = new Scanner(System.in);
System.out.printIn("Enter printed price of Digital Camera:");
double mrp = in.nextDouble();
double dis = mrp * 10 / 100.
double price = mrp - dis;
double gst = price * 6 / 100.0;
price = pricetgst;
System.out.printin("Amount to be pai=" + price);
}
}
Program 3. The time period of a Simple Pendulum is given by the formula:
T=2nvil/e)
Write a program to calculate the time period of a Simple Pendulum by taking length
and acceleration due to gravity (g) as inputs.
import java.util.*;
public class Pendulum_scan
{
public static void main(String args{]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter length: ");
double | = in.nextDouble();
System.out.print("Enter g ");
double g = in.nextDouble();
double t = 2 * (22.0 /7.0) * Math.sqrt(l/e);
System.out.printin("T="+t);Program 4. Write a program by using class 'Employee' to accept Basic Pay of an
employee.
Calculate the allowances/deductions as given below.
Allowance / Deduction Rate
Dearness Allowance (DA) 30% of Basic Pay
House Rent Allowance (HRA) 15% of Basic Pay
Provident Fund (PF) 12.5% of Basic Pay
Finally, find and print the Gross and Net pay.
Gross Pay = Basic Pay + Dearness Allowance + House Rent Allowance
Net Pay = Gross Pay - Provident Fund
import java.util.*;
public class Employee
{
public static void main(String argl]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Basic Pay: ");
double bp = in.nextDouble();
double da = 0.3 * bp;
double hra = 0.15 * bp;
double pf = 0.125 * bp;
double gp = bp + da + hra;
double np = gp - pf;
System.out.printIn("Gross Pay =" + gp);
System.out.printin("Net Pay =" +np);
yProgram 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
(b) the interest for the second year
(c) the amount after three years.
Take sum as an input from the user.
Sample Input: Principal = Rs.5000, Rate =10%, Time = 3 yrs
Sample Output: Interest for the first year: Rs.500
Interest for the second year: Rs.550
Interest for the third year: Rs.605
import java.util.*;
public class Compound_Interest{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter sum of money: ");
double p = in.nextDouble();
double interest = p * 5 *1/ 100.0;
System.out.printin("Interest for the first year =" + interest);
P=p+ interest;
interest = p*5 * 1/ 100.0;
System.out.printin("Interest for the second yea
p=p+ interest;
interest =p * 5 * 1/100.0;
System.out.printin("Interest for the third year = "+ interest);
}
}
Program 6. A businessman wishes to accumulate 3000 shares of a company. However,
he already has some shares of that company valuing %10 (nominal value) which yield
10% dividend per annum and receive £2000 as 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
to be purchased to make his target.
Hint: No. of share = (Annual dividend * 100) / (Nominal value * div %)
"+ interest);public class Shares_Divident
{
public static void main(String args[]) {
int s_held = (2000 * 100)/(10 * 10);
System.out.printin("No. of shares held currently =" + s_held);
int s_required = 3000 - s_held;
System.out.printin("No, of shares to purchase
}
}
+s_required);
Program 7. Write a program to input the time in seconds. Display the time after
converting them into hours, minutes and seconds.
Sample Input: Time in seconds 5420
Sample Output: 1 Hour 30 Minutes 20 Seconds
public class Second
{
public static void main(int sec) {
long hrs = sec / 3600;
sec =sec% 3600;
long mins = sec / 60;
sec =sec% 60;
System.out.printin(hrs +" Hours" + mins +" Minutes " + sec +" Seconds");
y
Program 8. A shopkeeper sells two calculators for the same price. He earns 20% profit
on one and suffers a loss of 20% on the other. Write a program to find his total cost
price of the calculators by taking selling price as input.
Hint: CP = (SP / (1 + (profit / 100))) (when profit)
CP = (SP /(1- (loss / 100))) (when loss)import java.util.*;
public class Shop
{
public static void main(String args{]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the selling price: ");
double sp = in.nextDouble();
double cp = (sp / (1 + (20 / 100.0)));
double cp2 = (sp / (1 - (20 / 100.0)));
double total_cp = cp + cp2;
System.out.printin("Total Cost Price =
}
}
+ total_cp);
Program 9. A certain amount is invested at the rate 10% per annum for 3 years.
Find the difference between Compound Interest (Cl) and Simple Interest (SI).
Write a program to take amount as an input.
Hint: SI = (P * R*T) / 100
A=P*(1+(R/100))T
Cl=A-P
import java.util.*;
public class SI_CI
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Amount: ");
double p = in.nextDouble();
double si=p * 10 * 3 / 100;
double ciAmt = p * Math.pow(1 + (10/100.0), 3);
System.out.print("Difference between Cl & SI:" +ciAmt);
double ci = ciAmt- p;
System.out.print( "Difference between Cl & SI:" + (ci- si));Program 10. Write a program to input two unequal numbers. Display the numbers
after swapping their values in the variables without using a third variable.
Sample Input: a= 23, b = 56
Sample Output: a = 56, b= 23,
class Swap
{
public static void main(String args{])
{
int a=23,b=56;
System.out.printin("a="+a+",b="+b);
}
}
Program 11. Write a program to input two unequal numbers. Display the numbers
after swapping their values in the variables using a third variable.
Sample Input: a = 23, b= 56
Sample Output: a = 56, b = 23
class Swap
{
public static void main(String args[])
{
int a=23,b=56,
tea;
b=t;
System.out.printin("a="+a+",b="+b);
}
}