Advertisement
SIRAKOV4444

Untitled

Apr 4th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exe4 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double N1 = Double.parseDouble(scanner.nextLine());
  8. double N2 = Double.parseDouble(scanner.nextLine());
  9. double result = 0;
  10. String operator = scanner.nextLine();
  11.  
  12.  
  13. if ("+".equals(operator)) {
  14. result = N1 + N2;
  15. if (result % 2 == 0) {
  16. System.out.printf("%.0f + %.0f = %.0f - even", N1, N2, result);
  17. } else {
  18. System.out.printf("%.0f + %.0f = %.0f - odd", N1, N2, result);
  19. }
  20.  
  21. } else if ("-".equals(operator)) {
  22. result = N1 - N2;
  23. if (result % 2 == 0) {
  24. System.out.printf("%.0f - %.0f = %.0f - even", N1, N2, result);
  25. } else {
  26. System.out.printf("%.0f - %.0f = %.0f - odd", N1, N2, result);
  27. }
  28. } else if ("*".equals(operator)) {
  29. result = N1 * N2;
  30. if (result % 2 == 0) {
  31. System.out.printf("%.0f * %.0f = %.0f - even", N1, N2, result);
  32. } else {
  33. System.out.printf("%.0f * %.0f = %.0f - odd", N1, N2, result);
  34. }
  35. } else if ("/".equals(operator)) {
  36. result = N1 / N2;
  37. System.out.printf("%.0f / %.0f = %.2f", N1, N2, result);
  38.  
  39. } else if ("%".equals(operator)) {
  40. result = N1 % N2;
  41. System.out.printf("%.0f %% %.0f = %.0f", N1, N2, result);
  42. }
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement