Hello guys! My first post here at JavaProgrammingForums, so thank you for having me!
I'm making a game to see how many digits of Pi you can get correct in a row; I'm sure it's been made before but I like doing stuff like this.
I ran this code and typed in "1" expecting for it to recognize that my input equaled the first digit to the right of pi.
The console looked like this;
"
Run:
1 //my input
10 //consoles output
Build Successful
"
Tried it a few more times, and it seems whatever I input the console multiplies it by 10 and spits out that answer. :S
Here is my code;
/* * Created By Josh Beckwith * on March 14, 2012. */ package pigame; import java.util.Scanner; public class PiGame { static int iPi01 = 1415926535; static int iPi02 = 897932384; static int iPi03 = 626433832; static int iPi04 = 795028841; static int iPi05 = 971693993; static int iPi06 = 751058209; static int iPi07 = 74944592; static int iPi08 = 30; static int iPi09 = 781640628; static int iPi10 = 620899862; static int iPi11 = 803482534; static int iPi12 = 211706798; static int iNumber; static int iDumber; static int iScore = 0; static boolean bCorrect = true; public static void main(String[] args) { for(int i = 1;bCorrect == true;i++) { //grab input and store as 'input' Scanner input = new Scanner(System.in); int iInt; iInt = input.nextInt(); System.out.print(iInt); if(i < 10) { iNumber = 10-i; iDumber = iPi01/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 19){ iNumber = 9-i; iDumber = iPi02/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 28){ iNumber = 9-i; iDumber = iPi03/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 37){ iNumber = 9-i; iDumber = iPi04/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 46){ iNumber = 9-i; iDumber = iPi05/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 55){ iNumber = 9-i; iDumber = iPi06/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 63){ iNumber = 8-i; iDumber = iPi07/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 65){ iNumber = 2-i; iDumber = iPi08/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 74){ iNumber = 9-i; iDumber = iPi09/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 83){ iNumber = 9-i; iDumber = iPi10/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 92){ iNumber = 9-i; iDumber = iPi11/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } else if (i < 101){ iNumber = 9-i; iDumber = iPi12/10^iNumber; if (iDumber != iInt) { bCorrect = false; } else if (iDumber == iInt) { iScore = iScore + 1; } } } //ends for loop System.out.println(iScore); } //ends method } //ends class