Advertisement
Guest User

Pr06_NumberGenerator

a guest
May 31st, 2017
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. package TheExam;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6. * Created by Minito on 7.5.2017 г..
  7. */
  8. public class Pr06 {
  9. public static void main(String[] args) {
  10. Scanner console = new Scanner(System.in);
  11. int m = Integer.parseInt(console.nextLine());
  12. int n = Integer.parseInt(console.nextLine());
  13. int l = Integer.parseInt(console.nextLine());
  14. int specNum = Integer.parseInt(console.nextLine());
  15. int contNum = Integer.parseInt(console.nextLine());
  16. boolean r1;
  17. boolean r2 = false;
  18. for (int i = m; i >= 1; i--) {
  19. for (int j = n; j >= 1; j--) {
  20. for (int k = l; k >= 1; k--) {
  21. int sum = Integer.valueOf(String.valueOf(i) + String.valueOf(j) + String.valueOf(k));
  22. r1 = false;
  23. if (sum % 3 == 0 && !r1) {
  24. specNum += 5;
  25. r1 = true;
  26. } else if (sum % 10 == 5 && !r1) {
  27. specNum -= 2;
  28. r1 = true;
  29. } else if (sum % 2 == 0 && !r1) {
  30. specNum *= 2;
  31. }
  32. if (specNum >= contNum) {
  33. System.out.print("Yes! Control number was reached! Current special number is " + specNum + ".");
  34. r2 = true;
  35. break;
  36. }
  37. }
  38. if (r2){
  39. break;
  40. }
  41.  
  42. }if (r2){
  43. break;
  44. }
  45. }if (!r2){
  46. System.out.printf("No! %d is the last reached special number.",specNum);
  47. }
  48.  
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement