KezraPlanes
Just some dood
Yeah that's my main reason for using it over '\n'.
Well I'm just only starting so with experience I'm sure I'll make choices that better my code and opting for endl just might be one of them.
I'm aware that \n is more confusing, but in my learning stages always having to type "<< endl;" can be a bother sometimes (since I code with limited time mostly).
But thanks for the constructive criticism.
Well, I translated gp1 into Java, and it appears to work fine. Only ~20 typos, new personal best. Had to lookup random and user input codes from Google though. . I also had it the wrong way around, where the user would be guessing the number. Maybe a diagram isn't such a bad idea after all.
Code:import java.io.*; import java.util.*; //Paul Colusso, 2010 //Java implementation of the gp1 "Number Guesser" public class gp1 { String userEntry; public static void main(String[] args) { int userNumber; int cpuNumber; int triesCounter = 0; Random numberGuess = new Random(); System.out.println("Welcome to Guess My Number\n\n"); System.out.println("Enter your guess (between 100 & 1): "); userNumber = getUserInput(); do { cpuNumber = numberGuess.nextInt(99) + 1; triesCounter++; if (userNumber < cpuNumber) { System.out.print("Too High! "); } else if (userNumber > cpuNumber) { System.out.print("Too Low! "); } } while (userNumber != cpuNumber); System.out.println("\n\nThe CPU guessed your number " + userNumber + " in " + triesCounter + " guesses"); } public static int getUserInput() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String userEntry; try { userEntry = br.readLine(); } catch (IOException ioe) { System.out.println("Error!"); System.exit(1); userEntry = "Failed"; } return Integer.parseInt(userEntry); } }
EDIT: It probably would have compiled fine in the hands of someone more experienced, but every time I see "ld: Symbol(s) not found" I run for the hills.
My app was ported to Java Well, at least part of it xD