wap to input 3 numbers and find the smallest of them using scanner class
Answers
Answered by
2
Program in java :
package (give package name);
import java.util.*;
public class (give class name)
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter first number : ");
double a=sc.nextDouble();
System.out.print("Enter second number : ");
double b=sc.nextDouble();
System.out.print("Enter third number : ");
double c=sc.nextDouble();
if ((a>b)&&(a>c))
System.out.println(a+" is the greatest number.");
else
if ((b>a)&&(b>c))
System.out.println(b+" is the greatest number.");
else
if ((c>a)&&(c>b))
System.out.println(c+" is the greatest number.");
}
}
I have done the program using double variable. You can do using Integer also.
Similar questions
Science,
1 month ago
English,
1 month ago
English,
3 months ago
India Languages,
3 months ago
Math,
9 months ago
Math,
9 months ago
Social Sciences,
9 months ago