AlexKondov

Java Simple Calculation

May 19th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Program {
  4.  
  5. public static void main(String[] args) {
  6. Scanner input = new Scanner(System.in);
  7. double x = input.nextDouble();
  8. double y = input.nextDouble();
  9.  
  10. if (x == 0 && y == 0) {
  11. System.out.println("0");
  12. }
  13. else if (x == 0) {
  14. System.out.println("5");
  15. }
  16. else if (y == 0) {
  17. System.out.println("6");
  18. }
  19. else if (x > 0 && y > 0) {
  20. System.out.println("1");
  21. }
  22. else if (x < 0 && y > 0) {
  23. System.out.println("2");
  24. }
  25. else if (x < 0 && y < 0) {
  26. System.out.println("3");
  27. }
  28. else if (x > 0 && y < 0) {
  29. System.out.println("4");
  30. }
  31. input.close();
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment