0% found this document useful (0 votes)
15 views5 pages

Set 1

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)
15 views5 pages

Set 1

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/ 5

SET 1

1. import java.util.Scanner;

public class apu2


{
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. public class Celsius
{
public static void main(String args[]) {
double f = 98.6;
double c = 5 * (f - 32) / 9.0;
System.out.println("Temperature in Degree Celsius = " + c);
}
}
3. public class ARYA
{
public static void main(String args[]) {
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;
System.out.println("Angle A = " + a);
System.out.println("Angle B = " + b);
System.out.println("Angle C = " + c);
System.out.println("Angle D = " + d);
}
}
4. import java.util.Scanner;

public class Empl


{
public static void main(String args[]) {
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);
}
}

5. import java.util.Scanner;

public class Price


{
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);
}
}
6. import java.util.Scanner;

public class NUMBER2


{
public void checkNumber() {

Scanner in = new Scanner(System.in);

System.out.print("Enter a 2 digit number: ");


int orgNum = in.nextInt();
int num = orgNum;
int count = 0, digitSum = 0, digitProduct = 1;

while (num != 0) {
int digit = num % 10;
num /= 10;
digitSum += digit;
digitProduct *= digit;
count++;
}

if (count != 2)
System.out.println("Invalid input, please enter a 2-digit number");
else if ((digitSum + digitProduct) == orgNum)
System.out.println("Special 2-digit number");
else
System.out.println("Not a special 2-digit number");

}
}
7. public class SPEED2
{
public static void main(String args[]) {

int distance = 240;


float speed = 60.0f;
float returnSpeed = speed - 20;

float time2Reach = distance / speed;


float time2Return = distance / returnSpeed;
float totalTime = time2Reach + time2Return;

float avgSpeed = (distance * 2) / totalTime;

System.out.println("Total time: " + totalTime);


System.out.println("Average speed: " + avgSpeed);
}
}
8. import java.util.Scanner;

public class ThreeDigitNumber {

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);

System.out.print("Enter a positive three-digit number: ");


int number = scanner.nextInt();

if (number >= 100 && number <= 999) {


int sum = 0;
int product = 1;
int temp = number;

while (temp > 0) {


int digit = temp % 10;
sum += digit;
product *= digit;
temp /= 10;
}

System.out.println("Sum of digits: " + sum);


System.out.println("Product of digits: " + product);
} else {
System.out.println("Invalid input");
}

scanner.close();
}
}
9. import java.util.Scanner;
public class AreaAndPerimeterOfSquare {
public static void main(String[] args) {
// Taking inputs from user
Scanner sc = new Scanner(System.in);
System.out.print("Enter the Length: ");
double length = sc.nextDouble();
sc.close();
double area = length * length;
double perimeter = 4 * length;
double diagonal = Math.sqrt(2) * length;
System.out.println("Area: " + area);
System.out.println("Perimeter: " + perimeter);
System.out.println("Length of diagonal: " + diagonal);
}
}
10. import java.util.Scanner;

public class EXAM


{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Marks");
System.out.print("Physics: ");
int p = in.nextInt();
System.out.print("Chemistry: ");
int c = in.nextInt();
System.out.print("Biology: ");
int b = in.nextInt();

double avg = (p + c + b) / 3.0;


long roundAvg = Math.round(avg);

System.out.println("Rounded Off Avg Marks = " + roundAvg);


}

You might also like