How to use Press Enter to Continue

Hello
how do i use press enter to continue in my programs
can i plz have the code

K here is my code
import java.io.*;
public class asn3
    public static void main (String [] args) throws Exception
        DataInput keyboard = new DataInputStream (System.in);
        int num = 0;
        String temp;
        String [] ques;
        String [] a, b, c, d, e;
        String [] ans;
        ques = new String [5];
        ques [0] = "(1) Which one of the following is an input device?";
        ques [1] = "(2) Which one of the following is an output device?";
        ques [2] = "(3)What does CPU stand for?";
        ques [3] = "(4)How many bytes in a megabyte";
        ques [4] = "(5)How many bytes in a gigabyte ?";
        a = new String [5];
        a [0] = "a) Printer";
        a [1] = "b) Monitor";
        a [2] = "c) Mouse";
        a [3] = "d) Speaker";
        b = new String [4];
        b [0] = "a) Mouse";
        b [1] = "b) Keyboard";
        b [2] = "c) Scanner";
        b [3] = "d) Speaker";
        c = new String [4];
        c [0] = "a) It does not stand for anything";
        c [1] = "b) Centeral Processing Unit";
        c [2] = "c) DUH!!!";
        c [3] = "d) City Power Unit";
        d = new String [4];
        d [0] = "a) 1";
        d [1] = "b) 1024";
        d [2] = "c) 4096";
        d [3] = "d) 1,048,576";
        e = new String [4];
        e [0] = "a) about 1 thousand";
        e [1] = "b) about 1 million";
        e [2] = "c) about 1 billion";
        e [3] = "d) about 1 trillion";
        ans = new String [5];
        ans [0] = "c";
        ans [1] = "d";
        ans [2] = "b";
        ans [3] = "d";
        ans [4] = "d";
        System.out.println ("\t\t\tWelcome to the quiz \n");
        System.out.println (ques [0] + "\n\n" + a [0] + "\n" + a [1] + "\n" + a [2] + "\n" + a [3]);
        System.out.print ("\nanswer : ");
        temp = keyboard.readLine ();
        if (temp.equals (ans [0]))
            System.out.println ("\n\nCorrect!!! \n");
            num = num + 1;
        else
            System.out.println ("\n\nWrong!!!\n\n");
        System.out.println (ques [1] + "\n\n" + b [0] + "\n" + b [1] + "\n" + b [2] + "\n" + b [3]);
        System.out.print ("\nanswer : ");
        temp = keyboard.readLine ();
        if (temp.equals (ans [1]))
            System.out.println ("\n\nCorrect!!! \n");
            num = num + 1;
        else
            System.out.println ("\n\nWrong!!!\n\n");
        System.out.println (ques [2] + "\n\n" + c [0] + "\n" + c [1] + "\n" + c [2] + "\n" + c [3]);
        System.out.print ("\nanswer : ");
        temp = keyboard.readLine ();
        if (temp.equals (ans [2]))
            System.out.println ("\n\nCorrect!!! \n");
            num = num + 1;
        else
            System.out.println ("\n\nWrong!!!\n\n");
        System.out.println (ques [3] + "\n\n" + d [0] + "\n" + d [1] + "\n" + d [2] + "\n" + d [3]);
        System.out.print ("\nanswer : ");
        temp = keyboard.readLine ();
        if (temp.equals (ans [3]))
            System.out.println ("\n\nCorrect!!! \n");
            num = num + 1;
        else
            System.out.println ("\n\nWrong!!!\n\n");
        System.out.println (ques [4] + "\n\n" + e [0] + "\n" + e [1] + "\n" + e [2] + "\n" + e [3]);
        System.out.print ("\nanswer : ");
        temp = keyboard.readLine ();
        if (temp.equals (ans [4]))
            System.out.println ("\n\nCorrect!!! \n");
            num = num + 1;
        else
            System.out.println ("\n\nWrong!!!\n\n");
          System.out.println ("--------------------------------------------------");
        System.out.println ("You answered " + num + " out of 5 questions correctly\n\n");
        if (num >= 5)
            System.out.println ("Grade A+ : You are Awesome\n\n ");
        else if ((num >= 4) && (num < 5))
            System.out.println ("Grade A : You did Great\n\n ");
        else if ((num >= 3) && (num < 4))
            System.out.println ("Grade C : You did Okay\n\n ");
        else
            System.out.println ("Grade F : You did Poorly\n\n ");
}just wanted to add press Enter to continue feature in the program
any more hints?
btw i have no clue about scanner class

Similar Messages

  • How to pause, say press enter to continue...

    Hi all,
    is there any scripts or documents for pause, say press enter to continue...?
    thanks
    andrew

    Try this:
    try
    byte[] b = new byte[2];
    System.in.read (b);
    } catch (IOException ex) {}

  • Press enter to continue...

    hi all,
    in my server /client model the clients log on and register ina vector class..since im working on distributed computing, time is important. so in my simulation, i wait for all the clients to log on and after i press enter, the server sends out the jobs.. this is how im doing..
    static String name
    System.out.println("press enter to continue");
    try
    name = br.readLine();
         }     catch(IOException e)
                   System.out.println(e);
    this does work fine. but depending upon number of clients, i have press enter key so many times. how to change this, so that by pressing just once, it is updated in all the clients.? or is there a better way to do this? using may be datastreaminput(i had read it but have forgotten the website).
    thank you
    ls

    Don't know if this is actual anymore but still (I'm in a situation when I can access the net only on weekends if I'm lucky)...
    You still ask the user to "press enter to continue" when ever you add a client since the codes for those two things are in the same place. You should move the code that asks for "enter" outside that method completely, that is:/* some code... */
    public void addClient(frequencies obj) {
    clientno = track ;
    track++;
    Clients.addElement(obj);
    System.out.println("client added");
    /* getting a handle to the callback object */
    f[clientno] = (frequencies)Clients.elementAt(clientno);
    client++;
    sendout(client -1);
    }//end of addclient
    /* some more code... */
    // call addClient in a loop here
    System.out.println("press enter to continue");
    try {
    name = br.readLine();
    } catch(IOException e) {
    System.out.println(e);
    /* and even more code... */

  • Selected boot image did not authentica​te. Press enter to continue

    I just removed the stock HDD that came with my M4-1015x and now I'm trying to install windows 7 to the SSD that I replaced it with. However, upon boot up I get the message "Selected boot image did not authenticate. Press <enter> to continue" when the laptop attempts to read the OS from the disc. I've never seen this before... any help? (It's a legitimate DVD copy of Windows 7)
    Thanks.
    This question was solved.
    View Solution.

    I fixed it. Had to disable secureboot and enable legacy boot mode to get it to run.

  • Message d'erreur "selected boot image did not authenticate. Press enter to continue.

    Jai le Message d'erreur "selected boot image did not authenticate. Press <enter> to continue."
    Jai vus dautre sujet comme cellui-ci mais moi il m'est impossible douvrir f10 poir desactiber le secure boot
    Merci de vos reponse

    Hi los,
    Thank you for visiting our English HP Support Forum. We are only able to reply to posts written in English. To insure a quick response it would be advisable to post your question in English. The following links are here to assist you if you prefer to post in the following Language Forum.
    English:                                 http://h30434.www3.hp.com
    Spanish:                               http://h30467.www3.hp.com
    French:                                 http://h30478.www3.hp.com
    Portuguese:                       http://h30487.www3.hp.com
    German:                              http://h30492.www3.hp.com
    Korean:                                http://h30491.www3.hp.com/t5/community/communitypage
    Simplified Chinese:         http://h30471.www3.hp.com/t5/community/communitypage
    Regards,
    George

  • How to use User entered dates in intreval

    Hi,
    User will enter date range in variable
    As per my requirment i want to use no of days between those 2 user entered dates in my calculaction
    How can i achieve this at report level.
    Thanks

    Hi
    Create a variable with intreval.
    There is a function module which calculates the no of days between the days
    Go to SE38 and ZXRSRU01 Program
    Write the Code like this (Not exact code)  you can modify
    WHEN "ZZZZZ"(Before that create a formula variable to get the number of days between the days and use the tech name of the formula variable here)
    read ..the lower limit and the upper limit of the caldaz variable
    FROMDATE = L_S_RANGE-low
    TODATE = L_S_RANGE-HIGH
    Then call the function module
    Search for the function module by using days in SE37
    Then pass the from and to Date to the function module it will retun the number of days
    update that to table e_T_Range
    You can proceed with this
    Regards
    M.A

  • Press Enter to Continue Movie

    Hi, I'm still new to using Flash and Actionscript and I was
    wondering if anyone could provide me with a quick code to get the
    Flash movie to stop on a certain frame and the continue when the
    user hits ENTER. I've tried experimenting with Actionscript and
    I've gotten the frame to stop/play but I keep getting errors when I
    try to code the push enter event. Any help would be
    appreciated.

    Put an invisible button on the stage (create a button with no
    content just a small hit area). Attach this code to the button:
    on(keyPress "<Enter>"){
    play();

  • How to use HOST call DOS continuous running problem but NOT hold Forms scre

    In my Forms, I have a Button a start a MP3 recorder program to record voice, I use HOST command to init the program successfully. However, since the MP3 recorder program in continuous running, the HOST command hold my Forms screen until the MP3 program stop.
    I have try to use Open_form to open another form to start this MP3 program. It still hold the whole Forms system.
    Is there any solution to start a continuous running DOS program but NOT hold the Forms screen?
    Thank You !

    You didn't provide your host-command, so i simply guess its something like
    HOST('"c:\Program Files\mp3.exe" someoptions');instead of calling the program directly, you could use a commadn batch along with the start-command, for this should launch the program asynchronously:
    HOST('cmd /c start "c:\Program Files\mp3.exe" someoptions');hope this helps.

  • How to use a loop with tokenizer

    I am working on an assignment where I need to use a loop to read input from a text file that contains grades. I'll use tokenizer (somehow) to read each line from the grade.txt file and then I need to output each test score, and calculate the average. So far this is my code:
    import java.io.*;
    import java.util.StringTokenizer;
      public class TestGrader
         public static void main (String[] args) throws FileNotFoundException,
                                                                     IOException
         BufferedReader keyboard = new
         BufferedReader(new InputStreamReader(System.in));
         BufferedReader inFile = new
         BufferedReader (new FileReader("c:java/homework/Assignment3/grades.txt"));
    /*******************Declare variables******************/
         int numOfTest, lowestScore, higestScore, avgScore;
         StringTokenizer tokenizer;
         tokenizer = new StringTokenizer(inFile.readLine());
         System.out.println("Enter the number of test you would like to grade: ");
         numOfTest = Integer.parseInt(keyboard.readLine());
         System.out.println("Press enter to continue...");
         keyboard.readLine();
         // Retrieve the test scores from the file grades.txtI'm stuck at the point where I need to create the loop to read the grades from the grades.txt file. Any help with the loop and tokenizer to read any number of grades would be appreciated.

    well i hope i am not too late to answer this.
    do u have any control on how to write the grades.txt file. If yes then follow:
    write the grades in following format:
    subject : marks separator(say ;) subject : marks separator(say ;)...... marksEOF(some new symbol)
    then try to process it using the following code
    while(!file.EOF()){
    StringTokenizer nk=new StringTokenizer(file.readLine(),separator);
    while(nk.hasMoreTokens()){
    //write code to display as nicely as you want...below is raw printing only....
    System.out.println(nk.nextToken());

  • How to use message in  EXIT_SAPLMGMU_001

    I am displaying a error message in the Exit 'EXIT_SAPLMGMU_001' . But the problem is the error message in been displayed like success message in the material master.
    Please let me know how to solve this problem.
    Regards,
    Arivu

    Hi Siva,
    Try this message:
          MESSAGE ID '00' TYPE 'E' NUMBER '435' WITH 'Please fill valid ' ' material to complete.Press enter to continue'.
    Thanks,
    AMS

  • Pressing ENTER in Command Prompt to solve hanging

    Hi,
    Does anyone know why sometimes Java hangs, unless you press ENTER in the
    Command Prompt for Windows 2K? After pressing ENTER it continues execution.
    It happens with WebLogic sometimes too. It will not print anything on the
    console until I press ENTER.
    I'm sure lots of Java developers have experienced this weird problem.
    Thanks,
    Duke
    [email protected]

    That is what we call a "feature" of an enterprise-class OS ;-)
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Chad McDaniel" <[email protected]> wrote in message
    news:[email protected]..
    On windows machines be very careful to turn off the "mark" option in
    the shell preferences. It can halt the server.
    Daniel Hoppe <[email protected]> writes:
    Hi,
    because you marked something in the command prompt. Marking stops
    execution. Enter means 'copy' and continues execution...
    Daniel
    -----Original Message-----
    From: Duke Nguyen [mailto:[email protected]]
    Posted At: Thursday, December 13, 2001 3:16 AM
    Posted To: ejb
    Conversation: pressing ENTER in Command Prompt to solve hanging
    Subject: pressing ENTER in Command Prompt to solve hanging
    Hi,
    Does anyone know why sometimes Java hangs, unless you press
    ENTER in the
    Command Prompt for Windows 2K? After pressing ENTER it
    continues execution.
    It happens with WebLogic sometimes too. It will not print
    anything on the
    console until I press ENTER.
    I'm sure lots of Java developers have experienced this weird problem.
    Thanks,
    Duke
    [email protected]

  • Itues 11. How do you make Podcasts play continuously. Right now they stop after each selection

    In iTunes 11 my podcasts stop after each selection. How do I play them continuosly as I was able to in iTunes 10?

    I second this motion of shenannigans.
    Upon updating to iTunes 11 I was unpleasantly surprised by the fact that my podcast smartlists no longer played continuously.
    So,
    Dear Apple, perhaps you want to fix the section on your website describing how to use a smartlist for continuity of podcast play, because it is not working as described http://www.apple.com/itunes/podcasts/.
    and yes, I too would like to know what's going on and how to fix it.

  • How to get input values till pressing enter key

    hi!!!
    i need to enter values thru keyboard using bufer reader etc etc
    but i need to stop entering when i press enter key
    how to do this??

    First off I would take a look at this link because it gives quite a few good examples if you've never used scanner.
    You can find all this on the link.-> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
    in order to use scanner you have to import it.
    import java.util.Scanner;then inside your main method you need to create a scanner wrapped around the keyboard inputstream.
    Scanner userIn = new Scanner(System.in);take a look at the api to decide which method you want. For this I would suggest nextLine().
    also I would specify that you want the numbers separated by spaces or comma's or something so you can use the String.split(" "); method which returns an array of Strings;
    then traverse through the array of strings and convert them to ints
    http://www.rgagnon.com/javadetails/java-0004.html

  • How to call some function by pressing Enter in JTextField

    Hi
    I have a following problem.
    In my app existing two JTextFields tfField1 and tfField2
    How to make when I type some text into tfField1 and press Enter the cursor will appear in tfField2?
    Setting the cursor into tfField2 is not a problem, I have realized this with tfField2.requestFocusInWindow();
    My problem is how to call this funktion [tfField2.requestFocusInWindow()] by pressing Enter on the keyboard

    Thanks a lot
    You are welcome.
    >
    I have an another question if you don't mindI don't mind at all. In the future, though, I recommend that you start a new thread if you have a completely different question.
    >
    I have 2 JFrames
    In JFrame 1 i have a button which opens JFrame2
    How to make that only JFrame2 will be active until it
    will be closed (so when JFrame2 is opened i can't do
    anything with the first JFrame1)
    Use a modal dialog instead of the second JFrame. Almost as easy as the textfield problem :-)
    You can read more about dialogs here:
    [url http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html]How to Make Dialogs

  • How to go to next field in tablerow by press Enter

    Hello SDN!
    I have a table with editable fields. Let's imagine that cursor is in field "A" in current row. User enter some data to current field and want cursor go to the next editable field in row by press Enter key.  How to do it? Is it possible?
    P.S. i'm working with NW 7.0
    regards, Lev

    Assign an action to the "onEnter" event of the input field for column "A" and implement the action handler as
    void onActionEnterPressedInFieldA(..., I<TableDataSourceNode>Element row)
      wdThis.wdGetAPI().requestFocus(row, wdContext.node<TableDataSource>().getNodeInfo().getAttribute(I<TableDataSourceNode>Element.ATTRIBUTE_B));
    Use event parameter mapping "nodeElement" -> "row" to pass the node element representing the table row to the action handler.
    Armin

Maybe you are looking for

  • How do I run totally sperate VI's from a compiled applicatio​n

    Hi, I have hit a wall here and am not sure which direction I should be moving in.  A relevant detail, running LV8.2 and application builder on Vista/XP.  Any suggestions on the approach I should be taking would be most helpful. I have a top level app

  • How to authorise many iPads with one Apple ID

    Hi all, This is for work purposes. Is it possible to have one Apple ID, authorised with multiple iPads, could be 30 or more? The iPads will be used for teaching so will all run the same apps. They are handed back in after class. I should say I want t

  • Migration 7.1.5 to 9.1.2 LAB

    Hi All, I've a scenario in which I'm currently running with cucm 7.1.5, and i want to upgrade it to cucm 9.1.2. I've a cluster of 5 cucm. in my lab I have the possibility to have 3 VM started simultaneously. Is it possible to upgrade my cluster into

  • I can't open my IPhone in iTunes because it has a password lock

    I haven't used the new itunes until now. When I connect my iphone I get a message in itunes saying that it cannot import from my iphone because it has a passcode. I didn't have this problem with an earlier version of itunes. So, when I plug my iphone

  • New VI function token in Labview Student Edition

    All experts out there, This VI mod_qam transmitter.vi token is not available in Student edition. How can i be able to create/find one? I am not able to search one in the Function Seach option. My objective is to create a M-ary QAM communication syste