Guest User

Untitled

a guest
Jul 13th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Necklace {
  3.  
  4. /**
  5. * @author christopher quijano
  6. * date: 3 21 12
  7. * @param args
  8. */
  9. public static void main(String[] args) {
  10. //variables
  11. Scanner input = new Scanner(System.in);
  12. int first,second;
  13. int t1,t2;
  14. boolean done;
  15.  
  16. //prompt user for input
  17. System.out.print("Enter first starting number : ");
  18. first = input.nextInt();
  19. System.out.print("Enter second starting number : ");
  20. second = input.nextInt();
  21.  
  22. //formulae for finding sum of numbers and displaying the numbers
  23. t1 = (first + second)%10;
  24. t2 = (second + t1)%10;
  25. System.out.print( first + " " + second + " " + t1 + " " + t2);
  26. done = (first == t1) && (second == t2);
  27.  
  28. //output
  29. while (!done)
  30. {
  31. t1 = (t1 + t2)%10;
  32. t2 = (t2 + t1)%10;
  33. System.out.print(" " + t1 + " " + t2);
  34. done = (first == t1) && (second == t2);
  35. }
  36.  
  37.  
  38.  
  39. }
  40.  
  41. }
Add Comment
Please, Sign In to add comment