Professional Documents
Culture Documents
Write A Java Application To Find The Maximum of Three Integers Entered by The User
Write A Java Application To Find The Maximum of Three Integers Entered by The User
Write A Java Application To Find The Maximum of Three Integers Entered by The User
5. Accept any three names from the keyboard and display “Your Name is” name.
6. Java Program to check Even or Odd number
7. WAP to accept 5 names from user and store them in an array and print them on screen in
order.
8. WAP to print highest and lowest total marks of 10 students using Arrays.
9. Write a program in Java to enable user to handle divide by zero exception
10. Write a program in Java to create class Triangle with the data members base, height,
area and color. The members base, height, area are of type double and color is of type
string. Write getter and setter methods for base, height and color, and write method to
compute_area (). Create two object of class Triangle, compute their area, and compare their
area and color. If area and color both are same for the objects then display "Matching
Triangles" otherwise display "Non matching Triangles".
import java.util.Scanner;
while(true) {
System.out.println("Press 1 for Addition");
System.out.println("Press 2 for Subtraction");
System.out.println("Press 3 for Multiplication");
System.out.println("Press 4 for Division");
System.out.println("Press 5 to Quit\n \n ");
case 1:
System.out.println("Enter the first number ");
a = scanner.nextInt();
System.out.println("Enter the second number");
b = scanner.nextInt();
c = a + b;
System.out.println("The sum of the numbers is = " + c +"\n");
break;
case 2:
System.out.println("Enter the first number ");
a = scanner.nextInt();
System.out.println("Enter the second number");
b = scanner.nextInt();
c = a - b;
System.out.println("The difference of the numbers is = " + c +"\n");
break;
case 3:
System.out.println("Enter the first number");
a = scanner.nextInt();
System.out.println("Enter the second number");
b = scanner.nextInt();
c = a * b;
System.out.println("The product of the numbers is = " + c + "\n");
break;
case 4:
System.out.println("Enter the first number");
a = scanner.nextInt();
System.out.println("Enter the second number");
b = scanner.nextInt();
c = a / b;
System.out.println("The quotient is = " + c +"\n");
break;
case 5:
System.exit(0);
default:
System.out.println("Invalid choice!!! Please make a valid choice. \\n\\n");
}
}
}
}
15. Write a Java program with method to print cube of a number