Write a program to to find sum of three numbers in Java

Java Programs

WAP to to find sum of three numbers

import java.io.*;
class greatest
{
public static void main(String args[]) throws IOException
{
int a,b,c;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter three numbers");
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
c=Integer.parseInt(br.readLine());
if(a>b && a>c)
{
System.out.println(a +" is greatest");
}
else
if(b>a && b>c)
{
System.out.println(b +" is greatest");
}
else
{
System.out.println(c +" is greatest");
}
}
}

Post a Comment

Previous Post Next Post