Hello, Thanks for the reply. I tried what you said and it worked for that line but on getting to tlMode and I enter a string that has spaces, it crashes.... but if i enter without spaces, it does not crash. it works fine without spaces if i entered something like "adadaff" . What is another way forward please?
Regards On Mon, Nov 15, 2010 at 11:19 PM, Alfred H. <[email protected]> wrote: > On Mon, Nov 15, 2010 at 11:42 PM, Olukosi, Olanrewaju Temitope > <[email protected]> wrote: > > Hello All, > > I really need your help here. I tried running this code but was having > > problem with the Scanner method. When it gets to the second input, it > skips > > to the third one. I mean when it gets to tName, it only prints the > > System.out.print statement and then prints the next statement without > giving > > the prompt input for the former statement. Kindly help check what I am > > getting wrong. > > Help guys. > > > > import java.util.Scanner; > > public class MineClass { > > private static int tNum, tMM, noQ; > > private static String tName, tFName, tIMode; > > private static double [] quizMark; > > /* > > * This method reads in all the values that will be needed for the > program. > > */ > > public static void main(String[] args){ > > Scanner in = new Scanner(System.in); > > System.out.print("TNNo: "); > > tNum = in.nextInt(); > > System.out.println("LFN: "); > > tName = in.nextLine(); > > System.out.println("TFN: "); > > tFName = in.nextLine(); > > System.out.print("IMM: "); > > tIMode = in.nextLine(); > > System.out.print("What To Cal?: "); > > noQ = in.nextInt(); > > quizMark = new double [noQ]; > > for (int a=0; a<noQ; a++){ > > System.out.print("The House No " + (a+1) +": "); > > quizMark[a] = in.nextDouble(); > > } > > System.out.println("Calsk: "); > > tMM = in.nextInt(); > > } > > } > > Regards > > -- > > DISCLAIMER > > This message contains privileged and confidential information and is > > intended only for the individual named. If you are not the intended > > recipient you should not disseminate, distribute, store, print, copy or > > deliver this message. Please notify the sender immediately by e-mail if > you > > have received this e-mail by mistake and delete this e-mail and any > > attachments from your system. E-mail transmission cannot be guaranteed to > be > > secure or error-free as information could be intercepted, corrupted, > lost, > > destroyed, arrive late or incomplete or contain viruses. The sender > > therefore does not accept liability for any errors or omissions in the > > contents of this message which arise as a result of e-mail transmission. > > Thank you -- Tope Olukosi > > > > -- > > To post to this group, send email to > > [email protected] > > To unsubscribe from this group, send email to > > [email protected]<javaprogrammingwithpassion%[email protected]> > > For more options, visit this group at > > http://groups.google.com/group/javaprogrammingwithpassion?hl=en > > try using next() to get String and System.out.print instead of println > -- DISCLAIMER This message contains privileged and confidential information and is intended only for the individual named. If you are not the intended recipient you should not disseminate, distribute, store, print, copy or deliver this message. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail and any attachments from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. Thank you -- Tope Olukosi -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
