COMPUTER
PROJECT
SHIVAM TULSIAN
9-A
43
S NO. TOPIC PAGE NO. SIGNATURE
1. BASIC ARITHMETIC 3 - 7
2. PENDULUM BASED 8
3. EMPLOYEE BASED 9
4. CAMERA PRICE BASED 10
5. DISCOUNT BASED 11
6. COMPOUND INTREST 12
BASED
7. SHARES BASED 13
8. TIME CONVERSION 14
INDEX
public class AddTwoNumbers {
public static void main(String[] args) {
int num1 = 5, num2 = 15, sum;
sum = num1 + num2;
System.out.println("Sum of these numbers: "+sum);
}
}
Output:
Sum of these numbers: 20
public class MyClass {
public static void main(String[] args) {
int x = 5; int y = 3;
System.out.println(x + y);
}
}
OUTPUT WILL BE 8
public class MyClass {
public static void main(String[] args) {
int x = 5; int y = 3;
System.out.println(x - y);
}
}
OUTPUT WILL BE 2
public class MyClass {
public static void main(String[] args) {
int x = 5; int y = 3;
System.out.println(x * y);
}
}
OUTPUT WILL BE 15
public class MyClass {
public static void main(String[] args) {
int x = 12; int y = 3;
System.out.println(x / y);
}
}
OUTPUT WILL BE 4
import java.util.Scanner;
public class KboatSimplePendulum
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter length: ");
double l = in.nextDouble();
System.out.print("Enter g: ");
double g = in.nextDouble();
double t = 2 * (22.0 / 7.0) * Math.sqrt(l/g);
System.out.println("T = " + t);
}
}
OUTPUT – T = 1.73889
import java.util.Scanner;
public class Employee {
public void computePay() {
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.println("Gross Pay = " + gp);
System.out.println("Net Pay = " + np);
}
}
OUTPUT – GP = 123250.0
NP = 112652
import java.util.Scanner;
public class KboatCameraPrice {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter printed price of Digital Camera:");
double mrp = in.nextDouble();
double disc = mrp * 10 / 100.0; double price = mrp - disc;
double gst = price * 6 / 100.0; price += gst;
System.out.println("Amount to be paid: " + price);
}
}
Output – 24803.046
import java.util.Scanner;
public class KboatDiscounts {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter price of article: ");
double price = in.nextDouble();
double d1 = price * 30 / 100.0;
double amt1 = price - d1;
System.out.println("30% discount = " + d1);
System.out.println("Amount after 30% discount = " + amt1);
double d2 = price * 20 / 100.0; double amt2 = price - d2;
double d3 = amt2 * 10 / 100.0; amt2 -= d3;
System.out.println("20% discount = " + d2);
System.out.println("10% discount = " + d3);
System.out.println("Amount after successive discounts = " + amt2);
Output – Amt after 30 % discount = 4666.65
Amt after 20% discount = 3111.1
Amt after 10% discount = 1244.44
Amt after successive discounts = 11199.96
import java.util.Scanner;
public class KboatCompoundInterest
{
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.println("Interest for the first year
= " + interest);
p += interest;
interest = p * 5 * 1 / 100.0;
System.out.println("Interest for the second year
= " + interest);
p += interest;
interest = p * 5 * 1 / 100.0;
System.out.println(“Intrest for the third year
=” + intrest);
}
}
Output – First year = 500
Second year = 525
Third year = 551.25
public class KboatShares
{
public static void main(String args[]) {
int sharesHeld = (2000 * 100)/(10 * 10);
System.out.println("No. of shares held
currently = "
+ sharesHeld);
int sharesRequired = 3000 - sharesHeld;
System.out.println("No. of shares to
purchase = "
+ sharesRequired);
}
}
Output – No of shares held currently – 2000
No of shares to purchase - 1000
import java.util.Scanner;
public class KboatTimeConvert
{
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 – 1hr 30 mins 20 secs