StefanTobler

Lesson 12 Activity 2

Sep 25th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. /*
  2.  * Lesson 12 Coding Activity 2
  3.  * Input two decimal numbers and print the largest.
  4.  * If the numbers are equal, print one of them.
  5.  *    
  6.  *     Sample Run 1
  7.  *        Please enter two numbers:
  8.  *        45.7
  9.  *        45.1
  10.  *
  11.  *        Largest is: 45.7
  12.  *        
  13.  *      Sample Run 2
  14.  *        Please enter two numbers:
  15.  *        14
  16.  *        14
  17.  *
  18.  *        Largest is: 14.0          
  19.  *
  20.  */
  21.  
  22.  
  23. import java.util.Scanner;
  24.  
  25. class Lesson_12_Activity_Two {
  26.     public static void main(String[] args)
  27.      {
  28.        Scanner scan = new Scanner(System.in);
  29.        
  30.        System.out.println("Enter two numbers: ");
  31.        
  32.        double x = scan.nextDouble();
  33.        double y = scan.nextDouble();
  34.        
  35.        if(x > y)
  36.        {  
  37.          System.out.println("Largest is: " + x);
  38.        }
  39.        if(x < y)
  40.        {  
  41.          System.out.println("Largest is: " + y);
  42.        }
  43.        if(x == y)
  44.        {  
  45.          System.out.println("Largest is: " + x);
  46.        }
  47.     }
  48. }
Add Comment
Please, Sign In to add comment