Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] shop(int[] shoplist, int credit)
- {
- boolean found = false;
- int i = 0;
- System.out.println("Your credit is: " + credit);
- while(!found)
- {
- int j = i + 1;
- while ( j != shoplist.length)
- {
- if(shoplist[i] + shoplist[j] == credit)
- {
- int[] shopped = new int[2];
- shopped[0] = i;
- shopped[1] = j;
- System.out.println("You bought " + (i+1) + " and " + (j+1));
- System.out.println("With values" + shoplist[i] + " and " + shoplist[j]);
- return shopped;
- }
- j++;
- }
- i++;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement