0% found this document useful (0 votes)
5 views6 pages

Set 2

The document contains multiple Java programs that perform various calculations, including swapping two numbers, calculating compound interest, determining the time in hours, minutes, and seconds from seconds, and computing discounts on prices. Other programs calculate the hypotenuse of a triangle, convert days into years, months, and days, and find the radius of a circle from its area. Each program uses the Scanner class to take user input and outputs the results of the calculations.

Uploaded by

mohuyadas980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Set 2

The document contains multiple Java programs that perform various calculations, including swapping two numbers, calculating compound interest, determining the time in hours, minutes, and seconds from seconds, and computing discounts on prices. Other programs calculate the hypotenuse of a triangle, convert days into years, months, and days, and find the radius of a circle from its area. Each program uses the Scanner class to take user input and outputs the results of the calculations.

Uploaded by

mohuyadas980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1. import java.util.

Scanner;

public class AAAA


{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter two unequal numbers");
System.out.print("Enter first number: ");
int a = in.nextInt();
System.out.print("Enter second number: ");
int b = in.nextInt();
a = a + b;
b = a - b;
a = a - b;
System.out.println("a = " + a + " b = " + b);
}
}

2. import java.util.Scanner;

public class bbbbbb


{
public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter the principal: ");


double principal = in.nextDouble();
System.out.println(principal);

float r1 = 6.0f, r2 = 8.0f, r3 = 10.0f;

double amount = principal * (1 + (r1 / 100)) * (1 + (r2 / 100)) * (1 + (r3 / 100));


double ci = amount - principal;

System.out.println("Amount after 3 years: " + amount);


System.out.println("Compound Interest: " + ci);
}
}
3. import java.util.Scanner;

public class ppppppppppppppp


{
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);
}
}

4. import java.util.Scanner;

public class ss
{
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);
}
}

5. import java.util.Scanner;

public class time


{
public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Time in seconds: ");


int inputTime = in.nextInt();

int hrs = inputTime / 3600;


int mins = (inputTime % 3600) / 60;
int secs = (inputTime % 3600) % 60;

System.out.println(hrs
+ " Hours "
+ mins
+ " Minutes "
+ secs
+ " Seconds");
}
}
6. import java.util.Scanner;

public class lll


{
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);
double ci = ciAmt - p;
System.out.print("Difference between CI & SI: " + (ci - si));
}
}

7. import java.util.Scanner;

public class mm
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the selling price: ");
double sp = in.nextDouble();
double cp1 = (sp / (1 + (20 / 100.0)));
double cp2 = (sp / (1 - (20 / 100.0)));
double totalCP = cp1 + cp2;
System.out.println("Total Cost Price = " + totalCP);
}
}
8. import java.util.Scanner;

public class jj
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Perpendicular: ");
double p = in.nextDouble();
System.out.print("Enter Base: ");
double b = in.nextDouble();

double h = Math.sqrt(Math.pow(p, 2) + Math.pow(b, 2));

System.out.println("Hypotenuse = " + h);


}
}

9. import java.util.Scanner;

public class kkkkkkkkkkk


{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter days: ");
int days = in.nextInt();
int years = days / 365;
days = days - (365 * years);
int months = days / 30;
int d = days - (months * 30);

System.out.println(years + " Years " + months + " Months " + d + " Days");
}
}
10. import java.util.Scanner;

public class Apu


{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Area of Circle: ");
double area = in.nextDouble();
double r = Math.sqrt(7 * area / 22);
System.out.print("Radius of Circle = " + r);
}
}

You might also like