2 errors. Can any1 amend the errors plz :-)

   This program lets the user play HighLow, a simple card game that is
   described in the output statements at the beginning of the main() routine.
   After the user plays several games, the user's average score is
   reported.
class HighLow {
   public static void main(String[] args) {
      int gamesPlayed = 0;     // Number of games user has played.
      int sumOfScores = 0;     // The sum of all the scores from all the
                               //      games played.
      double averageScore;     // Average score, computed by dividing
                               //      sumOfScores by gamesPlayed.
      boolean playAgain;       // Record user's response when user is asked
                               //   whether he wants to play another game.
      do {
         int scoreThisGame;        // Score for one game.
         scoreThisGame = play();   // Play the game and get the score.
         sumOfScores += scoreThisGame;
         gamesPlayed++;
         System.out.println("Play again? ");
         playAgain = TextIO.getlnBoolean();
      } while (playAgain);
      averageScore = ((double)sumOfScores) / gamesPlayed;
      System.out.println();
      System.out.println("You played " + gamesPlayed + " games.");
      System.out.println("Your average score was " + averageScore);
   }  // end main()
   static int play() {
         // Lets the user play one game of HighLow, and returns the
         // user's score in the game.
      Deck deck = new Deck();  // Get a new deck of cards, and store
                               //   a reference to it in the variable, Deck.
      Card currentCard;  // The current card, which the user sees.
      Card nextCard;     // The next card in the deck.  The user tries
                         //    to predict whether this is higher or lowe
                         //    than the current card.
      int correctGuesses ;  // The number of correct predictions the
                            //   user has made.  At the end of the game,
                            //   this will be the user's score.
      char guess;   // The user's guess.  'H' if the user predicts that
                    //   the next card will be higher, 'L' if the user
                    //   predicts that it will be lower.
      deck.shuffle();
      correctGuesses = 0;
      currentCard = deck.dealCard();
      System.out.println("The first card is the " + currentCard);
      while (true) {  // Loop ends when user's prediction is wrong.
         /* Get the user's predition, 'H' or 'L'. */
         System.out.println("Will the next card be higher (H) or lower (L)?  ");
         do {
             guess = TextIO.getlnChar();
             guess = Character.toUpperCase(guess);
             if (guess != 'H' && guess != 'L')
                System.out.println("Please respond with H or L:  ");
         } while (guess != 'H' && guess != 'L');
         /* Get the next card and show it to the user. */
         nextCard = deck.dealCard();
         System.out.println("The next card is " + nextCard);
         /* Check the user's prediction. */
         if (nextCard.getValue() == currentCard.getValue()) {
           System.out.println("The value is the same as the previous card.");
            System.out.println("You lose on ties.  Sorry!");
            break;  // End the game.
         else if (nextCard.getValue() > currentCard.getValue()) {
            if (guess == 'H') {
                System.out.println("Your prediction was correct.");
                correctGuesses++;
            else {
                System.out.println("Your prediction was incorrect.");
                break;  // End the game.
         else {  // nextCards is lower
            if (guess == 'L') {
                System.out.println("Your prediction was correct.");
                correctGuesses++;
            else {
                System.out.println("Your prediction was incorrect.");
                break;  // End the game.
         /* To set up for the next interation of the loop, the nextCard
            becomes the currentCard, since the currentCard has to be
            the card that the user sees, and the nextCard will be
            set to the next card in the deck after the user makes
            his prediction.  */
         currentCard = nextCard;
         System.out.println();
         System.out.println("The card is " + currentCard);
      } // end of while loop
      System.out.println();
      System.out.println("The game is over.");
      System.out.println("You made " + correctGuesses + " correct predictions.");
      System.out.println();
      return correctGuesses;
   }  // end play()
} // end class HighLow

The program also uses a class card
   An object of class card represents one of the 52 cards in a
   standard deck of playing cards.  Each card has a suit and
   a value.
public class Card {
    public final static int SPADES = 0,       // Codes for the 4 suits.
                            HEARTS = 1,
                            DIAMONDS = 2,
                            CLUBS = 3;
    public final static int ACE = 1,          // Codes for the non-numeric cards.
                            JACK = 11,        //   Cards 2 through 10 have their
                            QUEEN = 12,       //   numerical values for their codes.
                            KING = 13;
    private final int suit;   // The suit of this card, one of the constants
                              //    SPADES, HEARTS, DIAMONDS, CLUBS.
    private final int value;  // The value of this card, from 1 to 11.
    public Card(int theValue, int theSuit) {
            // Construct a card with the specified value and suit.
            // Value must be between 1 and 13.  Suit must be between
            // 0 and 3.  If the parameters are outside these ranges,
            // the constructed card object will be invalid.
        value = theValue;
        suit = theSuit;
    public int getSuit() {
            // Return the int that codes for this card's suit.
        return suit;
    public int getValue() {
            // Return the int that codes for this card's value.
        return value;
    public String getSuitAsString() {
            // Return a String representing the card's suit.
            // (If the card's suit is invalid, "??" is returned.)
        switch ( suit ) {
           case SPADES:   return "Spades";
           case HEARTS:   return "Hearts";
           case DIAMONDS: return "Diamonds";
           case CLUBS:    return "Clubs";
           default:       return "??";
    public String getValueAsString() {
            // Return a String representing the card's value.
            // If the card's value is invalid, "??" is returned.
        switch ( value ) {
           case 1:   return "Ace";
           case 2:   return "2";
           case 3:   return "3";
           case 4:   return "4";
           case 5:   return "5";
           case 6:   return "6";
           case 7:   return "7";
           case 8:   return "8";
           case 9:   return "9";
           case 10:  return "10";
           case 11:  return "Jack";
           case 12:  return "Queen";
           case 13:  return "King";
           default:  return "??";
    public String toString() {
           // Return a String representation of this card, such as
           // "10 of Hearts" or "Queen of Spades".
        return getValueAsString() + " of " + getSuitAsString();
} // end class Cardamd a class deck
    An object of type Deck represents an ordinary deck of 52 playing cards.
    The deck can be shuffled, and cards can be dealt from the deck.
public class Deck {
    private Card[] deck;   // An array of 52 Cards, representing the deck.
    private int cardsUsed; // How many cards have been dealt from the deck.
    public Deck() {
           // Create an unshuffled deck of cards.
       deck = new Card[52];
       int cardCt = 0; // How many cards have been created so far.
       for ( int suit = 0; suit <= 3; suit++ ) {
          for ( int value = 1; value <= 13; value++ ) {
             deck[cardCt] = new Card(value,suit);
             cardCt++;
       cardsUsed = 0;
    public void shuffle() {
          // Put all the used cards back into the deck, and shuffle it into
          // a random order.
        for ( int i = 51; i > 0; i-- ) {
            int rand = (int)(Math.random()*(i+1));
            Card temp = deck;
deck[i] = deck[rand];
deck[rand] = temp;
cardsUsed = 0;
public int cardsLeft() {
// As cards are dealt from the deck, the number of cards left
// decreases. This function returns the number of cards that
// are still left in the deck.
return 52 - cardsUsed;
public Card dealCard() {
// Deals one card from the deck and returns it.
if (cardsUsed == 52)
shuffle();
cardsUsed++;
return deck[cardsUsed - 1];
} // end class Deck

Similar Messages

  • My friends put cydia on my ipod and other stuff from it like something who slide your apps differently how can i remove the both, plz help ..???

    My friend put cydia on my ipod and other stuff from it like something who slide your apps differently. How can I remove the both, I really want, plz help ...?

    They hacked it and may have caused damage to your device. Jailbreaking also voids your warranty and support from Apple. To restore to a clean state, restore in Recovery Mode: http://support.apple.com/kb/HT1808

  • I published my site - created a second one - can't amend the 1st one now!

    I created a website using iWeb. I used "Publish to folder".
    I uploaded this to my ftp - site works great.
    I created a new site, deleting the pages of the first. I used "Publish to folder".
    I uploaded this to my ftp - site works great.
    Now, iWeb is incapable of editing my first site! Imagine selling something to people that only works one way?
    Why include "Publish to Folder" if you won't "Import from folder".
    Very frustrating!

    You didn't need to delete the first site to create and work on a second site. You can have multiple sites in one domain file as shown in the screenshot below. Notice the two sites Demo_1 and Demo_2 in the left hand pane.
    Click to view full size
    The iWeb video tutorials at Apple are very helpful - http://www.apple.com/ilife/tutorials/#iweb
    OT

  • Can any1 provide the notes on "ABAP dictionary"

    can any one provid me the the notes of "ABAP dictionary" .
    Edited by: rajeel jain on Jun 22, 2011 10:57 AM
    Moderator Message: Please read the [Forum Rules Of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] before posting your question
    Edited by: Suhas Saha on Jun 22, 2011 2:54 PM

    Hello venkat,
    Please check this link, It might be helpful to you. I believe you have written the code for custom button in the events.
    http://help-abap.blogspot.com/2008/09/add-custom-button-on-maintianence-view.html
    try to use insert statement in the event for the custom button. Let me know the peice of code you have written for this custom button.
    Thanks & Regards,
    Nagaraj Kalbavi

  • Can i amend the background text in a title?

    i would like a red background behind my white text for a title.
    The animation is so that the text and background appear from the left
    I have been unable to find a background colour setting
    Any help on this would be great -
    i have tried to build a custom one in Motion which works ok, but thought it might be already possible in FCP X
    Thanks
    Mark

    Use a colored generator and put it underneath the text.

  • HT5621 I have an old email address linked to my iphone so cannot sign into iCloud.  How can I amend the email link so I can update

    iCloud on my iPhone 4s uses an old email address so I am unable to update the phone.  I do not have the password and cannot re-set using the old email.

    Maybe this could help:
    http://www.apple.com/support/appleid/

  • Amend the rules in BCM

    Hi  All,
    How can i  amend the rules in BCM  (Bank Communication Management) to accept payments from USD  0  onwards asap.
    As we need the capability to make payments under USD 1 for all entities.
    Thanks & Regards
    vishwaas

    If you are using APP for payment to vendors, then in FBZP go to Paying company codes step, there give zero for the following fields.
    Minimum amount for incoming payment
    Minimum amount for outgoing payment
    Rgds
    Murali. N

  • I downloaded songs to my phone at xmas and when i plugged in to my laptop it wiped the phone of new purchases when i try and download them to my computer in itunes via previous purchesses it wont load the list and i keep getting error 10053 can any1 help

    i downloaded songs to my phone at xmas and when i plugged in to my laptop it wiped the phone of new purchases when i try and download them to my computer in itunes via previous purchesses it wont load the list and i keep getting error 10053 can any1 help

    Syncing shouldn't trouch you photos unless you have photos in a Photo Library album.  These would be photos that were synced to your phone from your computer.  If you do have any, you'll need to use an app like PhotoSync to transfer them to your computer prior to syncing.
    If you prefer to backup your camera roll photos prior to syncing, open iTunes and go to Preferences>Devices and check "Prevent...from syncing automatically".  Then connect your phone to your computer and import them as explained here: http://support.apple.com/kb/HT4083.
    Then, to minimize data loss, follow the steps in this user tip: https://discussions.apple.com/docs/DOC-3141.  To follow the steps, first open iTunes and go to View>Show Sidebar.  Also, Transfer Purchases is now located in File>Devices.

  • My ipod is showing corrupted.. iam updating by itunes but its show error 1439.. can any1 help me

    my ipod is showing corrupted.. iam updating by itunes but its show error 1439.. can any1 help me

    Hey there AftabskinHow are you?
    Well, I have an iPod Classic, it gave me the error -1436 error and would not restore on iTunes.
    I did the following:
    My Boss (@work) has a fairly old iBook but it has OS-X, so I decided to give it a try and connected my iPod to it.
    The system showed a window telling me that the disk is not MAC formated and needs to be validated prior further action. Snce it is a Mac product, I thought "yeah, go ahead".
    It then opens the disk manager utility for the Mac and showed the disk. It's window has some tabs, one is to verify the disk, so I verified it. Guess what, it had some invalid clusters.
    Then I formatted the iPod to OS-X Plus file system (next tab to the right). After formating the iPod, I "ejected" the iPod and reconnected to my PC. The Windows iTunes found an iPod with Mac file system and asked me to restore it. As I clicked on the "restore" button, I crossed my fingers as this was the last resource I have.
    Finally, after the file extraction was done, it began to restore the iPod!!
    I'm so happy about being able to restore the iPod that I decided to share with all you guys this solution as it is the most usefull, in my opinion.
    Hope you can find someone with an iBook or a desktop Mac, so you can fix yours.
    If it works for you, make sure to share the tip!!
    Kind regards
    Salvador Rivera

  • I can't download the apple ios 5 for the ipad. after downloading around 10 % an error no. 3259 occurs. it's a network error. please help . it's urgent. i am having apple ipad 2 3G wifi

    i can't download the apple ios 5 for the ipad. after downloading around 10 % an error no. 3259 occurs. it's a network error. please help . it's urgent. i am having apple ipad 2 3G wifi.

    i switched off all the security settings and all the firewalls.
    i m unable to install any of the app on the ipad
    so i saw the apple support and it said to update the older version of my ipad.
    and niether am i able to download the update nor am i able to download any app and install it in my ipad2
    i also tried to download an .ipsw file (ios5 update) from torrentz bt i am also unable to install from that as itunes rjects that file and gives an error. and also tries to delete that file. plz anyone help urgently.

  • Firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"

    firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"

    you have not understood my point
    how does this code will run on servlet when I want to upload a file from client's
    machine to server machine
    what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
    All the computers are connected in LAN
    So how to upload a file from client's machine to server's machine
    Plz give me a solution

  • " Can not interpret the data in file " error while uploading the data in DB

    Dear All ,
    After running the below report I am getting the " Can not interpret the data in file " error.
    Need to upload the data in DB through excel or .txt file.
    Kindly advise to resolve the issue.
    REPORT  ZTEST_4.
    data : it like ZPRINT_LOC occurs 0 with header line,
    FILETABLE type table of FILE_TABLE,
    wa_filetable like line of filetable,
    wa_filename type string,
    rc type i.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    CHANGING
    FILE_TABLE = filetable
    RC = rc.
    IF SY-SUBRC = 0.
    read table filetable into wa_filetable index 1.
    move wa_filetable-FILENAME to wa_filename.
    Else.
    Write: / 'HI'.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = wa_filename
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
    TABLES
    DATA_TAB = it.
    IF SY-SUBRC = 0.
    Write: / 'HI'.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    insert ZPRINT_LOC from table it.
    if sy-subrc = 0.
    commit work.
    else.
    rollback work.
    endif.
    Regards
    Machindra Patade
    Edited by: Machindra Patade on Apr 9, 2010 1:34 PM

    Dear dedeepya reddy,
    Not able to upload the excel but have sucess to upload the .csv file to db through the below code. Thanks for your advise.
    REPORT  ZTEST_3.
             internal table declaration
    DATA: itab TYPE STANDARD TABLE OF ZPRINT_LOC,
          wa LIKE LINE OF itab,
          wa1 like line of itab.
                       variable  declaration
    DATA: v_excel_string(2000) TYPE c,
           v_file LIKE v_excel_string VALUE    'C:\Documents and Settings\devadm\Desktop\test.csv',  " name of the file
            delimiter TYPE c VALUE ' '.         " delimiter with default value space
         read the file from the application server
      OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    write:/ 'error opening file'.
      ELSE.
        WHILE ( sy-subrc EQ 0 ).
          READ DATASET v_file INTO wa.
          IF NOT wa IS INITIAL.
            append wa TO itab.
          ENDIF.
          CLEAR wa.
        ENDWHILE.
      ENDIF.
    CLOSE DATASET v_file.
    EXEC SQL.
         TRUNCATE TABLE "ZPRINT_LOC"
    ENDEXEC.
    *------display the data from the internal table
    LOOP AT itab into wa1.
    WRITE:/ wa1-mandt,wa1-zloc_code,wa1-zloc_desc,wa1-zloc,wa1-zstate.
    ENDLOOP.
    insert ZPRINT_LOC from table itab.

  • HT5312 I DO remember them but Apple chose to put them in Japanese and I can not change the language on Manage my Apple ID so I do not know if I made an error ,it threw me off , it was the wrong question Where did you fly to on your first Aiplane trip ? th

    I DO remember them but Apple chose to put them in Japanese and I can not change the language on Manage my Apple ID so I do not know if I made an error ,it threw me off , it was the wrong question Where did you fly to on your first Aiplane trip ? then I was unable to enter until 8 hours then called Apple Japan 4 times each time threy asked me would you like to speak with an English speaker,I said yes then they told me sorry today is Sunday no English speakers ,but they refused to speak Japanese, then I called 5th time and a kind guy could speak English we were on 1and 1/2 hours he got me to log in but the reset key chain could not be completed still pending.
    He said do not mess with that ! then I got a text from somewhere to reset 4 pins suddenly it was very strange I said to him that I got this pin this morning but it said you can use maximum 3 hours it had a UK number and I told him I do not like this and will not enter the code he said do not do it if it is from the UK and then I said to him ok you did a lot to help but we can not go any further ! and we cut of I went back to my computer to re do the ID but I found everything a mess so I call and a stupid sounding Japanese women with a squeaky voice came on I was calm at first and they want your phone number your IMEI number your iPhone serial number date of birth Address email address it takes 10 munutes to check then they ask what are you caling about so I try to explain my keychain is broken or problems with language security questions and can not change my pasword because the security question have failed me so it is ONE BIG HEADACHE AND I START I GET STRESSED she says Do want an ENGLISH speaker ,I say yes ,that guy i talked to earlier but I never got his name and first time I ever talked to him but they said he is not here so I said ok and then she said today is sunday so call back in the morning ,I said ,well ok in Japanese but they make you feel stupid because they do not want to speak Jap@anese with none natives and they are to busy,And they feel that I should not bother them ,then I say that Apple Japan is trying to refuse Apple foreign customers and then she wants to hang up and ask me to visit the shop ,but they are the same I have a very bad time with Apple Japan since they do not discuss software problems or security with customer meaning if you have a problem they ask you to come on a time 20 minutes max so they do hardware test and say you phone is fine then I say no I can not reset my ID they say you must call call centre so I am going around in circles ,When I call English it is usually Australia so if my problem is in Japan surely if do not want me to talk to them in Japanese and they ask me to call Australia but every time my call charge is expensive after asking them is this free because I have Apple care they say yes but when the call goes to Australia 0120 277 535 it might change to paid call so I call then I have to ask is this charging they say we can not give you that information ! so what can I do I have have been at the computer and phone all day on my day off work and in tre week I am so busy and can not use my phone I can not work without it ,this new technology for you ,they can not cope with the fact that the customer have problems yet they do not want to deal with us because they can not solve it and so it shows them to be useless they like to walk around in their cool tee shirts and retro shop but when it comes to functionality we are unwelcome they got the money so do not return because apple is perfect that nothing should go wrong .
    But it does somehow my English security answers do not work on a Japanese Question especialy if I did not choose that question I set  up the multiple choice In English and wrote the answers in English or Roman and set them langauge preferences in English, do you really think you can correctly write english name or word in Japanese they write a police patrol car  pato caa パトカア they do not have r and l .So it is my choice to make my security easy for me and as difficult for others to hack.But they also have patororoo choo meaning ' now patrolling ' so why they have pato caa patrol car and patoro patrol and have thousands of Chinese words kanji they can find patrol.
    I am getting off the topic but I am at a loss to fix this problem when they hold the keys and i have all the info to verify my ID.

    You have to enter the Apple ID and password. You are running into the Activation Lock
    iCloud: Find My iPhone Activation Lock in iOS 7
    Is there a way to find my Apple ID Name if I can't remember it?
    Yes. Visit My Apple ID and click Find your Apple ID. See Finding your Apple ID if you'd like more information.
    How do I change or recover a forgotten Apple ID Password?
    If you've forgotten your Apple ID Password or want to change it, go to My Apple ID and follow the instructions. SeeChanging your Apple ID password if you'd like more information.

  • Media Encoder CC 2014.0.1 error on install: I can't unpack the downloaded files (translation).

    I have troubles with the latest update of Media Encoder CC (2014). I get an error which says: I can't unpack the downloaded files (translated from Dutch). Please try again. I try again, but it don't help. I have a MacPro early 2008 with Mavericks.
    =======================================
    Moderator moved thread from Premiere Pro forum to AME, and trimmed the title.

    Looks like one component in Media Encoder is either missing or corrupted somehow.
    Could you uninstall Adobe Media Encoder CC 2014 and please make sure all files are deleted after uninstall?  Then, please try re-installing it.

  • Error "can not start the configuration in parallel does not correct"

    Hello everybody,
    I have Windows 7 SP1, and when I install Business Objects 4.1 Client, it is install correctly but when i execute the program, for example BO Rich Client, an error appear "can not start the configuration in parallel does not correct" Could you help me?
    Thanks in advance!

    Check this KB
                  1678498  - BI 4.0 Universe Designer Gives Side-by-Side configuration incorrect Error

Maybe you are looking for

  • Why can't I access the top portions of a website I'm visiting when using firefox?

    I'll use facebook for an example, but bear in mind that this problem is when ever I go on any website. When I signed on facebook, my mouse turns into an arrow and it won't allow me to select anything on the top/upper portion of the website. I have to

  • Product Costing - Process Order Confirmation

    Dear Experts, We are facing a situation with our Product Costing Scenario : Under SFG Process Order Confirmation, there are Ten Phases to finally confirm the order. First Phase is for Raw Material Issuance. From Second Phase to Ninth Phase are releva

  • Networking PC's and Servers with a iMac

    Just got my first Mac a few days ago plugged it in saw all devices: 1 PC XP SP 2 1 HP MediaServer 1 HP Laptop Vista Now the Mac cannot see any devices through the LAN : Tried enabling NetBios - still no luck Any suggestions to get my Mac to see ll th

  • Validation popup conflicting with confirmation popup

    I am using 11gR1. I have a form with three buttons on it CreateInsert, Next, Cancel. The next button fires model layer validation on a new record, the cancel button opens a confirmation popup and if the user clicks yes, navigates the away from the fo

  • Error when generating Live Data Report from CUIC in CUCX 10

    Hello Guys, I have a problem generating Live Reports on CUIC (UCCX 10 deployment). I receive the following error: "Error updating the filter information. XMPP Messaging infrastructure error" All the services are IN SERVICE Any ideas??