Advertisement
Guest User

ABC problem done in JAVA

a guest
Jan 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. /**
  5. *
  6. * @author JARVIS-MAIN
  7. */
  8. public class AbcIsWhat {
  9.  
  10. /**
  11. * @param args the command line arguments
  12. */
  13. public static void main(String[] args) {
  14. Scanner scan = new Scanner (System.in);
  15. double a = 0, b = 0, c = 0, count = 1;
  16.  
  17. System.out.println("Do you to stop the program if you reach an ");
  18. System.out.println("answere to the ABC problem? (enter yes or no)");
  19. String ans = scan.nextLine();
  20.  
  21. for (int a1 = 1; a1 <= 9; a1++) {
  22. a = (double) a1;
  23. for (int b1 = 1; b1 <= 9; b1++) {
  24. b = (double) b1;
  25. for (int c1 = 1; c1 <= 9; c1++) {
  26. c = (double) c1;
  27. System.out.println("======[" + count + "]=====");
  28. System.out.println("a: " + a);
  29. System.out.println("b: " + b);
  30. System.out.println("c: " + c);
  31.  
  32. double part1 = joinNumber(a,b,c) / 5;
  33. double part2 = (a * b * c);
  34. System.out.println("part 1: " + part1);
  35. System.out.println("part 2: " + part2);
  36. if (part1 == part2) {
  37. System.out.println("======[EQUAL]=====");
  38. System.out.println("part 1: " + part1);
  39. System.out.println("part 2: " + part2);
  40. if(ans.equalsIgnoreCase("yes")){
  41. System.exit(0);
  42. }
  43. }
  44. count++;
  45. }
  46. }
  47. }
  48. }
  49.  
  50. public static double joinNumber(double a, double b, double c) {
  51. double send = (100 * a) + (10 * b) + (1 * c);
  52. return send;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement