Results 1 to 2 of 2

Thread: Help me please.

  1. #1
    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Exclamation Help me please.

    hi again,

    why it will be infinite loop ? i can't find,what can i do for playing one by one between computer and user ? thank you

    package work1;

    import java.util.*;

    public class work1 {

    public static void main(String[] args) {

    Scanner s = new Scanner(System.in);

    System.out.println("welcome to the card game,easy or hard ? (for easy,press 1,for hard,press 2)");

    int easyHard = s.nextInt();

    Random r = new Random();

    int totalCard=r.nextInt(90)+10;



    if(easyHard == 1)
    {




    for (int computer=1; computer<=totalCard/2 ; computer--)
    {
    for(int user=1; user<=totalCard/2; user--)
    {
    if(computer==1)

    System.out.println("you won !");

    if(user==1)

    System.out.println("computer won !");


    }

    }
    }

    if(easyHard== 2)
    {


    for(int computer=1; computer<=Math.pow(2, totalCard)-1; computer--)
    {
    for(int user=1; user<=Math.pow(2, totalCard)-1; user--)
    {
    if(computer==1)

    System.out.println("you won !");


    if(user==1)

    System.out.println("computer won !");

    }


    }




    }






    }

    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,238
    Rep Power
    19

    Default Re: Help me please.

    In your previous thread I referred you to the forum rules and also provided links for you to learn how to post code here. As you have again violated the forum rules in respect of the subject line, I'm closing this thread.

    Please feel free to start another thread that is in compliance with the rules, and with the code posted as outlined in the links on your earlier thread.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •