INPUT STATEMENT1
INPUT STATEMENT1
Question 1
T = 2π√(l/g)
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.*;
Output
Variable Description
Write a program by using class 'Employee' to accept Basic Pay of an employee. Calculate the
allowances/deductions as given below.
import java.util.*;
Output
Variable Description
Question 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.
import java.util.*;
Question 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.
Take the price of an article as the input.
import java.util.*;
Output
Question 5
Mr. Agarwal invests certain sum at 5% per annum compound interest for three years. Write a
program in Java to calculate:
import java.util.*;
Output
Question 6
Import java.util.*;
public class Shares
{
public static void main()
{
int numshare = (2000 * 100)/(10 * 10);
System.out.println("No. of shares held currently = "
+ numshare);
int sharesRequired = 3000 - numshare;
System.out.println("No. of shares to purchase = "
+ sharesRequired);
}
}
Output
Question 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
import java.util.*;
public class convert
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter time in seconds: ");
long secs = in.nextLong();
long hrs = secs / 3600;
secs %= 3600;
long mins = secs / 60;
secs %= 60;
System.out.println(hrs + " Hours " + mins
+ " Minutes " + secs + " Seconds");
}
}
Output
Question 8
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
import java.util.*;
Output
Question 9
A certain amount is invested at the rate 10% per annum for 3 years. Find the difference
between Compound Interest (CI) 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
CI = A - P
import java.util.*;
Output
Question 10
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.*;
Output
Variable Description