Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- // A girl counting on her left hand’s fingers,
- //u need to tell on which finger she will stop for a giving number.
- //Counting was like 1-thumb, 2-index finger ,
- //3-middle finger, 4-ring finger,5-little finger then 6-ring,
- //7-middle , 8-index, 9 thumb , 10 -index and so on ..
- public class thumb_finger_problem {
- public static void main(String[] args) {
- String[] hand = new String[] {"thumb","index","middle","ring","little"};
- System.out.println("enter where you want to stop her: ");
- Scanner scan = new Scanner(System.in);
- int number = scan.nextInt();
- //System.out.println(number);
- if(number<=0)
- System.out.println("You enter less than zero");
- if(number>5) {
- number=number-5;
- int i = number/4;
- int k = number%4;
- if(i%2==0) {
- System.out.println(hand[4-k]);
- }
- else
- System.out.println(hand[k]);
- }
- else
- System.out.println(hand[number-1]);
- }
- }
Add Comment
Please, Sign In to add comment