Computer Applications
Write an if statement to find the smallest of the three given integers using the min() method of the Math class.
Java Conditional Stmts
91 Likes
Answer
if (a < Math.min(b, c))
System.out.println(a);
else
System.out.println(Math.min(b, c));
Answered By
62 Likes
Related Questions
Rewrite the following if statement, using the switch statement:
if (choice == 1) System.out.println("You selected One"); else if (choice == 2) System.out.println("You selected Two"); else if (choice == 3) System.out.println("You selected Three"); else if (choice == 4) System.out.println("You selected Four"); else if (choice == 5) System.out.println("You selected Five"); else if (choice == 6) System.out.println("You selected Six"); else System.out.println("Invalid choice");
Write the following switch statement by using nested if statements:
switch (choice) { case 0: case 1: x = 111; y = 222; break; case 2: x = 333; y = 444; break; case 3: x = -11; y = -22; break; default: y = 555; }
Find the error in the given statement:
int x = (a => b) ? "a" : "b";
Find the error, if any, in the following code. Write the correct statement.
int a=5, b=10; int x = (a>b)>true:false;