Guest User

Untitled

a guest
Jul 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. // A girl counting on her left hand’s fingers,
  4. //u need to tell on which finger she will stop for a giving number.
  5. //Counting was like 1-thumb, 2-index finger ,
  6. //3-middle finger, 4-ring finger,5-little finger then 6-ring,
  7. //7-middle , 8-index, 9 thumb , 10 -index and so on ..
  8.  
  9. public class thumb_finger_problem {
  10.  
  11. public static void main(String[] args) {
  12. String[] hand = new String[] {"thumb","index","middle","ring","little"};
  13. System.out.println("enter where you want to stop her: ");
  14. Scanner scan = new Scanner(System.in);
  15. int number = scan.nextInt();
  16. //System.out.println(number);
  17. if(number<=0)
  18. System.out.println("You enter less than zero");
  19. if(number>5) {
  20. number=number-5;
  21.  
  22. int i = number/4;
  23. int k = number%4;
  24. if(i%2==0) {
  25. System.out.println(hand[4-k]);
  26. }
  27. else
  28. System.out.println(hand[k]);
  29.  
  30. }
  31. else
  32. System.out.println(hand[number-1]);
  33. }
  34.  
  35.  
  36.  
  37. }
Add Comment
Please, Sign In to add comment