Monday, 28 May 2012

application that reads three nonzero value entered by the user and determines and prints sum, product, average, smallest & largest of three

import java.util.Scanner.*;
import java.util.*;

class UserInput

public static void main(String args[])
Scanner s =new Scanner(;
System.out.println("Enter First number :  ");
int num1=s.nextInt();
System.out.println("Enter Second number :  ");
int num2=s.nextInt();
System.out.println("Enter Third number :  ");
int num3=s.nextInt();

int sum =num1+num2+num3;
System.out.println("Sum  :  "+sum);

int prod =num1*num2*num3;
System.out.println("Product  :  "+prod);

float avg =sum/3;
System.out.println("Average  :  "+avg);

if (num1>num2&&num1>num3)
System.out.println("num1 is greater");
if (num2>num1&&num2>num3)
System.out.println("num2 is greater");
if (num3>num1&&num3>num2)
System.out.println("num3 is greater");

if (num1<num2&&num1<num3)
System.out.println("num1 is smaller");
if (num2<num1&&num2<num3)
System.out.println("num2 is smaller");
if (num3<num1&&num3<num2)
System.out.println("num3 is smaller");


1 comment:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes