ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

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

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 12 May 2017 My Price 9.00

writing a Java program from scratch

Can someone please help me with this rock paper scissors program? I have most of the code I believe it just doesn't compile the way my teacher would like it to. There are strict ways I need this done, if it isn't done the way I need it please do not post the code to get me more confused. This Must bedone using nested if statements/ if-else!!

Overview

You will be writing a Java program from scratch that plays the game Rock, Paper, Scissors with a human opponent. This program randomly generates a choice for itself, takes an choice from the user, and determines a winner based on the rules of Rock, Paper, Scissors.

Objectives

Practice with programming fundamentals

Variables - Declaration and Assignment

Primitive types

Simple keyboard input and text display output

Branching: if-else if-else syntax, nested if-else syntax

Works towards the following Course Goals:

Competency with using basic coding features of a high-level imperative programming language

Competency with writing computer programs to implement given simple algorithms

Familiarity with designing simple text-oriented user interfaces

Project 04 Description

For this lab you will write a Java program that will play a simple game of Rock, Paper, Scissors. If you have never played this game before the rules are simple - each player chooses one of Rock, Paper or Scissors and they reveal their choices simultaneously. The choice of Rock beats the choice of Scissors ("Rock smashes Scissors"), the choice of Scissors beats the choice of Paper ("Scissors cut Paper"), and the choice of Paper beats Rock ("Paper covers rock"). If both players choose the same item, they tie.

Your program will generate a random choice of Rock, Paper or Scissors. It should then prompt the user for their choice. It should report both choices and indicate who wins the game. In addition, it should check the user's input and if the user inputs an invalid choice it should replace the user's choice with a valid default choice instead.

Following the instructions from Closed Lab 01, create a new folder named Project04 and a new Java program in that folder named Project04.java for this assignment.

Project 04 Sample Ouptut

This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.

Please select one of [R/P/S]: R
You chose: Rock
I chose: Paper
Paper beats rock - you lose!

Your code will behave differently based on the random value it selects and the choice taken by the user. Here is a second possible execution of this code:

Please select one of [R/P/S]: S
You chose: Scissors
I chose: Paper
Scissors beats paper - you win!

In the case of a tie, your code should report a tie:

Please select one of [R/P/S]: P
You chose: Paper
I chose: Paper
A Tie!

If the user enters an invalid choice, your code should default to a valid choice. This code defaults to Rock if the user doesn't enter a valid choice:

Please select one of [R/P/S]: q
Invalid choice! Defaulting to Rock.
I chose: Rock
A Tie!

For this assignment you should allow the user to enter either capital or lowercase letters to make their choice:

Please select one of [R/P/S]: r
You chose: Rock
I chose: Paper
Paper beats rock - you lose!

NOTE: To generate a random choice, you will need to use the Math.random() function as used in Lab 03. You will need to modify it to select an integer value between 1 and 3 and assign Rock, Paper or Scissors according to the number generated (for example, you might decide that 1 is Paper, 2 is Rock and 3 is Scissors)

Answers

(11)
Status NEW Posted 12 May 2017 12:05 AM My Price 9.00

-----------

Attachments

file 1494549055-Solutions file 2.docx preview (51 words )
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 -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)