Hi
I have modified the code ,please go through it.If any difficulty then revert
back.
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){
//MineClass in = new MineClass(System.in);
Scanner sc = new Scanner(System.in);
System.out.print("TNNo: ");
tNum = sc.nextInt();
System.out.println("tNum"+tNum);
Scanner sc1 = new Scanner(System.in);
System.out.println("LFN: ");
tName = sc1.nextLine();
System.out.println("tName"+tName);
Scanner sc2 = new Scanner(System.in);
System.out.println("TFN: ");
tFName = sc2.nextLine();
System.out.println("tFName"+tFName);
Scanner sc3 = new Scanner(System.in);
System.out.print("IMM: ");
tIMode = sc.nextLine();
System.out.println("tIMode"+tIMode);
System.out.print("What To Cal?: ");
noQ = sc.nextInt();
System.out.println("noQ"+noQ);
quizMark = new double [noQ];
for (int a=0; a<noQ; a++){
System.out.print("The House No " + (a+1) +": ");
quizMark[a] = sc.nextDouble();
}
System.out.println("Calsk: ");
tMM = sc.nextInt();
System.out.println("tMM"+tMM);
}
}
Thanks and Regards
RAHUL SINGH
From: [email protected]
[mailto:[email protected]] On Behalf Of Olukosi,
Olanrewaju Temitope
Sent: Tuesday, November 16, 2010 12:12 AM
To: [email protected]
Subject: [java programming] Java Error using Scanner(System.in)
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]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
________________________________
DISCLAIMER:
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE
COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact the
sender by email and delete all copies; your cooperation in this regard is
appreciated.
--
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