Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Necklace {
- /**
- * @author christopher quijano
- * date: 3 21 12
- * @param args
- */
- public static void main(String[] args) {
- //variables
- Scanner input = new Scanner(System.in);
- int first,second;
- int t1,t2;
- boolean done;
- //prompt user for input
- System.out.print("Enter first starting number : ");
- first = input.nextInt();
- System.out.print("Enter second starting number : ");
- second = input.nextInt();
- //formulae for finding sum of numbers and displaying the numbers
- t1 = (first + second)%10;
- t2 = (second + t1)%10;
- System.out.print( first + " " + second + " " + t1 + " " + t2);
- done = (first == t1) && (second == t2);
- //output
- while (!done)
- {
- t1 = (t1 + t2)%10;
- t2 = (t2 + t1)%10;
- System.out.print(" " + t1 + " " + t2);
- done = (first == t1) && (second == t2);
- }
- }
- }
Add Comment
Please, Sign In to add comment