Description Create a project called Daily15 Add a C source f

Description: Create a project called Daily15. Add a C source file to the project named daily15.c. Write a program to score the paper-rock-scissors game AGAIN. Each of two players enters either P, R, or S. The program then announces the winner as well as the basis for determining the winner: \"Paper covers rock\", \"Rock breaks scissors\", \"Scissors cut paper\", or \"Draw, nobody wins\" The primary differences between this and previous two versions are described as below (1) You MUST use a function to get the input value for the player\'s choice. The players must be able to enter either upper-or lower-case letters. If an invalid choice is entered, the player should be permitted to re-enter his choice immediately (before the other player is given a chance to enter their value). The function returns an enumerated type (e.g., Choice) that has possible three values, ROCK, PAPER, and SCISSORS (the one you defined in the previous version). This makes it so that the only part of your program that pertains to the player choices that can involve character variables is the input portion. The rest of your program should always use variables of the enumerated Choice type. (2) you MUST use a function, e.g., checkWinner, to compare two choices, decide the winner, and print the result on the screen. This means that the function takes two Choice type arguments (ie player1\'s choice and player2\'s choice) and returns nothing. Use breakpoints to watch the formal parameter values when the function is called if needed. (3) this program must allow the players to continue playing as long as desired by asking them after each game if they would like to play again. Comparing with using functions, what is the difference if you write all of the code directly in the main function? Describe what you think in the comment header (1 point) Your program output should look something like the following:

Solution

public class Daily15

{

    public static void main(String[] args)

    {

        Player player1 = new Player();

        Player player2 = new Player();

        String name;

        String playagain;

        int firstUserScore =0;

        int secondUserScore =0;

        char playAgainOrNot;

        Scanner keyboard = new Scanner(System.in);

       System.out.println(\"Hello and welcome to the Guess Number Game.\");

        System.out.println(\"Please enter your first name player 1\");

        name= keyboard.next();

        player1.setName(name);

        System.out.println(\"Please enter your first name player 2\");

        name = keyboard.next();

        player2.setName(name);

        do

        {

            System.out.println(\"What you would like to play? \" + player1.getName());

            System.out.println(\"Rock, paper, or scissors \");

               String user1Input = keyboard.next();

            user1Input = user1Input.toUpperCase();

           System.out.println(\"What you would like to play? \" + player2.getName());

            System.out.println(\"Rock, paper, or scissors \");

            String user2Input = keyboard.next();

            user2Input = user2Input.toUpperCase();

            char firstLetterUser1 = user1Input.charAt(0);

            char secondLetterUser2 = user2Input.charAt(0);

            if(firstLetterUser1 == secondLetterUser2)

            {

                System.out.println(player1.getName() +\" chose \" + user1Input);

                System.out.println(player2.getName() + \" chose \" + user2Input);

                System.out.println(\"It\'s a tie!\");

                firstUserScore++;

                secondUserScore++;

                player1.setScore(firstUserScore);

                player2.setScore(secondUserScore);

            }

                  else if (firstLetterUser1 != secondLetterUser2)

            {

             

                if(firstLetterUser1 == \'R\' && secondLetterUser2 == \'S\')

                {

                    System.out.println(player1.getName() +\" chose \" + user1Input);

                    System.out.println(player2.getName() + \" chose \" + user2Input);

                    System.out.println(player1.getName() + \" wins!\");

                    firstUserScore++;

                    player1.setScore(firstUserScore);

                }

                else if (secondLetterUser2 == \'R\' && firstLetterUser1 == \'S\')

                {

                    System.out.println(player1.getName() +\" chose \" + user1Input);

                    System.out.println(player2.getName() + \" chose \" + user2Input);

                    System.out.println(player2.getName() + \" wins!\");

                    secondUserScore++;

                    player2.setScore(secondUserScore);

                }

                else if (firstLetterUser1 == \'P\' && secondLetterUser2 == \'R\')

                {

                    System.out.println(player1.getName() +\" chose \" + user1Input);

                    System.out.println(player2.getName() + \" chose \" + user2Input);

                    System.out.println(player1.getName() + \" wins!\");

                    firstUserScore++;

                    player1.setScore(firstUserScore);

                }

                else if (secondLetterUser2 == \'P\' && firstLetterUser1 == \'R\')

                {

                    System.out.println(player1.getName() +\" chose \" + user1Input);

                    System.out.println(player2.getName() + \" chose \" + user2Input);

                    System.out.println(player2.getName() + \" wins!\");

                    secondUserScore++;

                    player2.setScore(secondUserScore);

                }

                else if (firstLetterUser1 == \'S\' && secondLetterUser2 ==\'P\')

                {

                    System.out.println(player1.getName() +\" chose \" + user1Input);

                    System.out.println(player2.getName() + \" chose \" + user2Input);

                    System.out.println(player1.getName() + \" wins!\");

                    firstUserScore++;

                    player1.setScore(firstUserScore);

                }

                else if (secondLetterUser2 == \'S\' && firstLetterUser1 == \'P\')

                {

                    System.out.println(player1.getName() +\" chose \" + user1Input);

                    System.out.println(player2.getName() + \" chose \" + user2Input);

                    System.out.println(player2.getName() + \" wins!\");

                    secondUserScore++;

                    player2.setScore(secondUserScore);

                }

            }

            System.out.println(\"Would you like to play again \" + player1.getName() + \" and \" + player2.getName());

            System.out.println(\"Please enter Y/N\");

            playagain = keyboard.next();

            playagain = playagain.toUpperCase();

            playAgainOrNot = playagain.charAt(0);

        }

        while (playAgainOrNot == \'Y\');

        System.out.print(player1.toString() + \" \ \" + player2.toString());

    }

}

 Description: Create a project called Daily15. Add a C source file to the project named daily15.c. Write a program to score the paper-rock-scissors game AGAIN.
 Description: Create a project called Daily15. Add a C source file to the project named daily15.c. Write a program to score the paper-rock-scissors game AGAIN.
 Description: Create a project called Daily15. Add a C source file to the project named daily15.c. Write a program to score the paper-rock-scissors game AGAIN.
 Description: Create a project called Daily15. Add a C source file to the project named daily15.c. Write a program to score the paper-rock-scissors game AGAIN.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site