SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Dec 2017 My Price 8.00

public static void main(String[] args) Scanner keyboard

Need help adding a line of code that tells the player1 and player2 invalid input if they do not choose the correct choice, here is the code

 

 public static void main(String[] args) {

       Scanner keyboard = new Scanner(System.in);

       

       while (true)

       {

       int Rock = 1, Paper = 2, Scissors = 3;

       int player1, player2;

       int player1wins = 0;

       int player2wins = 0;

       int ties = 0;

       int count = 0;

 

       System.out.println("First to 5!");

       while (count<5)

       {

       System.out.println("Player 1 Enter Rock = 1, Paper = 2, or Scissors = 3:");

       player1 = keyboard.nextInt();

       System.out.println("Player 2 Enter Rock = 1, Paper = 2, or Scissors = 3:");

       player2 = keyboard.nextInt();

       

       if ((player1 == 1) && (player2 == 1))

       {

           System.out.println("Tie!");

           ties++;

           count++;

       }

       else if ((player1 == 2) && (player2 == 2))

       {

           System.out.println("Tie!");

           ties++;

           count++;

       }

       else if ((player1 == 3) && (player2 == 3))

       {

           System.out.println("Tie!");

           ties++;

           count++;

       }

       else if ((player1 == 1) && (player2 == 3))

       {

           System.out.println("Player 1 Wins!");

           player1wins++;

           count++;

       }

       else if ((player1 == 2) && (player2 == 1))

       {

           System.out.println("Player 1 Wins!");

           player1wins++;

           count++;

       }

       else if ((player1 == 3) && (player2 == 2))

       {

           System.out.println("Player 1 Wins!");

           player1wins++;

           count++;

       }

       else if ((player1 == 1) && (player2 == 2))

       {

           System.out.println("Player 2 Wins!");

           player2wins++;

           count++;

       }

       else if ((player1 == 2) && (player2 == 3))

       {

           System.out.println("Player 2 Wins!");

           player2wins++;

           count++;

       }

       else if ((player1 == 3) && (player2 == 1))

       {

           System.out.println("Player 2 Wins!");

           player2wins++;

           count++;

       }

       }

       if(player1wins == 5)

       {

           System.out.println("Player 1 Total:" + player1wins);

           System.out.println("Player 2 Total:" + player2wins);

           System.out.println("Player 1 Wins!");

       }

       else if(player2wins == 5)

       {

           System.out.println("Player 1 Total:" + player1wins);

           System.out.println("Player 2 Total:" + player2wins);

           System.out.println("Player 2 Wins!");   

       }   

       System.out.println("Play again? "Yes" or "No"");

       Scanner YN = new Scanner(System.in);

       String YN_String = YN.next();

       if(YN_String.equals("Yes") || YN_String.equals("yes"))

       {

       }

       if(YN_String.equals("No") || YN_String.equals("no"))

       {

               System.out.println ("Goodbye!");

               break;

       }

   }

}

} 

Answers

(5)
Status NEW Posted 12 Dec 2017 12:12 PM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)