Guest User

Untitled

a guest
Dec 13th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AddNumbers{
  4.  
  5. public static void main(String [] args) {
  6. //variables
  7. double x, y, z;
  8.  
  9. System.out.println("Enter two numbers to calculate their sum!");
  10.  
  11. Scanner in = new Scanner(System.in);
  12.  
  13. try {
  14.  
  15. System.out.println("First number: ");
  16. x = in.nextDouble();
  17. System.out.println("Second number: ");
  18. y = in.nextDouble();
  19.  
  20. z = x + y;
  21.  
  22. System.out.println("The sum is = " + z);
  23. }
  24. catch (InputMismatchException e) {
  25.  
  26. }
  27.  
  28. System.out.println("You fucked up, idiot.");
  29. }
  30.  
  31. }
Add Comment
Please, Sign In to add comment