I do noT undErstaNd why my pRogram inSists on continUing to aSk for a new Student, eveN after I have told my while Loop "no".
Just wondeRing if Anyone can helP me.
-Ki
public class MainClass { static private int nextStudent = 0; static StudentInformation Student[] = new StudentInformation[100]; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static boolean addAnotherStudent = true; public static void main(String[] args) { while (addAnotherStudent == true) { addStudent(); System.out.println("Would you like to add another Student?"); try { String temp = br.readLine(); if (temp == "no") { System.out.println("No more students to enter, Good bye"); addAnotherStudent = false; } else { addAnotherStudent = true; } } catch (IOException ioExcption) { System.out.println("IO exception occurred!"); System.exit(1); } } } public static void addStudent(){ StudentInformation new1 = new StudentInformation(); System.out.println("Enter your Student Information: "); System.out.println("Enter student's full name: "); try { new1.setName(br.readLine()); } catch (IOException ioExcption) { System.out.println("IO exception occurred!"); System.exit(1); } System.out.println("What is your address? "); try { new1.setAddress(br.readLine()); } catch (IOException ioExcption) { System.out.println("IO exception occurred!"); System.exit(1); } System.out.println("What is your city? "); try { new1.setCity(br.readLine()); } catch (IOException ioExcption) { System.out.println("A double was not entered!"); System.exit(1); } System.out.println("What is your state? "); try { new1.setState(br.readLine()); } catch (IOException ioExcption) { System.out.println("IO exception occurred!"); System.exit(1); } System.out.println("What is your zipcode? "); try { new1.setZipcode(br.readLine()); } catch (IOException ioExcption) { System.out.println("IO exception occurred!"); System.exit(1); } System.out.println("What is your current GPA? "); try { new1.setCurrentGPA(Double.parseDouble(br.readLine())); } catch (IOException ioExcption) { System.out.println("A double was not entered!"); System.exit(1); } System.out.println("Student's Information: "); System.out.println(new1.getName()); System.out.println(new1.getAddress()); System.out.println(new1.getCity()); System.out.println(new1.getState()); System.out.println(new1.getCurrentGPA()); Student[nextStudent] = new1; ++ nextStudent; } }


LinkBack URL
About LinkBacks
Reply With Quote


by clicking the
button on their useful posts.
for anybody who wishing to read more into it, maybe those who didn't know this here's a link, but read carefully otherwise you may think there is a === operator 