/* * Autor: Juan Antonio Ripoll * Date: 30/10/13 * * Write a JAVA program to get three numbers * from the user and display the greatest one. * */ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the first number: "); int number1 = in.nextInt(); System.out.print("Enter the second number: "); int number2 = in.nextInt(); System.out.print("Enter the third number: "); int number3 = in.nextInt(); if (number1 > number2) if (number1 > number3) System.out.println("The greatest: " + number1); if (number2 > number1) if (number2 > number3) System.out.println("The greatest: " + number2); if (number3 > number1) if (number3 > number2) System.out.println("The greatest: " + number3); } }
Wednesday, October 30, 2013
2.05 - Greatest of three numbers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment