Making a program which is meant to be able to store information about students, their names, phonenumbers, certain grades etc. I'm all done with the whole program except for one small thing. I want the program to understand that if someone writes i.e. 123 in the field where they should write their name, the program should instead say it's an invalid text, it needs to be in letters. I want similar things on all options, like when the person who uses the program should write the grades, i want them to be able to write nothing except for "ig", "g", "vg", or "mvg" (Swedish grades). Started on the grades so far, can't get them to work though, it's no problem to javac the file, but as soon as I try to run it, it doesn't work the way it should (or at least the way I want it too...)
Anyway, here's the bit that I'm having problems with (sorry for the swedish):
"Betyg 1" and "Betyg 2" are the ones I have started with so far (which are the grades).
switch (Val){ case '1': System.out.println("Namn: "); String namn = Keyboard.readString(); //Want something here that makes "rules" for the name, meaning you can only use letters here. System.out.println("Personnummer: "); String pn = Keyboard.readString(); //Want this one to be able to be only digits and always exactly 10. System.out.println ("Betyg 1: "); String betygEtt = Keyboard.readString(); if (betygEtt != "ig" || betygEtt != "g" || betygEtt != "vg" || betygEtt != "mvg"){ System.out.println ("Icke giltigt betyg 1."); } System.out.println ("Betyg 2: "); String betygTvå = Keyboard.readString(); if (betygTvå != "ig" || betygTvå != "g" || betygTvå != "vg" || betygTvå != "mvg"){ System.out.println ("Icke giltigt betyg 2."); } System.out.println ("Telefonnummer: "); String tfn = Keyboard.readString(); //Want this one to be able to be only digits.
Would really appreciate if anyone could help me a little bit, at least give some tips, I'm meant to send this to my teacher tonight, really wanna get it done in time :/