CSE PROGRAM #5 Solution

$30.00 $24.00

Outcomes: Use a contemporary programming language and programming environment Write, compile, edit, and debug simple Java programs Write Java programs that use conditional expressions Write Java programs that manipulate strings Write Java programs that use Math.random() method Format and comment source code that adheres to a given set of formatting guidelines Use a zip compression…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:

Description

5/5 – (2 votes)

Outcomes:

  • Use a contemporary programming language and programming environment

  • Write, compile, edit, and debug simple Java programs

  • Write Java programs that use conditional expressions

  • Write Java programs that manipulate strings

  • Write Java programs that use Math.random() method

  • Format and comment source code that adheres to a given set of formatting guidelines

  • Use a zip compression tool to combine multiple files

Requirements: You will write two separate Java programs

  1. Create a folder on your computer named program5. All your source code files should be created in this folder.
  1. The table below summarizes three commonly used mathematical models of non nonvertical straight lines.

In a class named LineForm, write a program that permits the user to convert either two-point form or point-slope form into slope-intercept form. Your program should interact with the user as follows:

Example1:
Select the form that you would like to convert to slope-intercept form:
1) Two-point form (you know two points on the line)
2) Point-slope form (you know the line’s slope and one point)
=> 2

Enter the slope=> 4.2
Enter the x-y coordinates of the point separated by a space
=> 1 1
Point-slope form
y – 1.00 = 4.20(x – 1. 00)


Slope-intercept form
y = 4.20x – 3.20

Example2:
Select the form that you would like to convert to slope-
intercept form:
1) Two-point form (you know two points on the line)
2) Point-slope form (you know the line’s slope and one point)
=> 1

Enter the x-y coordinates of the first point separated by a
space=> 4 3

Enter the x-y coordinates of the second point separated by a
space=> -2 1


Two-point form
(1.00 – 3.00)
m= ——————–
(-2.00 – 4.00)

Slope-intercept form
y=0.33x+1.66

In the comments at the top of this class, include a list of test cases you used, along with the results of those test cases (even if those results were incorrect).

  1. In a class named RockPaperScissors you are to write a human vs. computer Rock Paper Scissors game. In the game of “Rock Paper Scissors”, two players each choose one of three weapons: rock, paper, or scissors. The human types her weapon choice on the keyboard (the word rock, paper, or scissors – shown in red). The computer randomly selects a weapon. Then, your program should display whether the human or computer wins, or if the game ended in a tie.

The winner is determined based on the following:

  • Rock beats scissors

  • Scissors beats paper

  • Paper beats rock

  • If both players choose the same weapon, it is a tie

Some requirements:

  1. Use String variables for the human weapon and for the computer weapon.
  2. For the human move, allow the user to type her choice as String variable in any mix of uppercase or lowercase. The user must type the entire word (not just R, P, or S).

  3. For the computer move, use Math.random() to help you generate a random int value of either 0, 1, or 2. Then choose the computer’s weapon based on that choice.

  4. Use some combination of if statements, else statements, &&, ||, or whatever else is needed to determine who wins the game.

Here are three sample runs of the program:

Match this format as closely as possible (including quotation marks, spacing, periods at the ends of sentences, and so on).

Welcome to “Rock, Paper, Scissors”.

What is your move? Rock

Human plays rock. The computer plays paper.

Computer wins.

Welcome to “Rock, Paper, Scissors”.

What is your move? sCiSSoRs

Human plays scissors. The computer plays scissors.

Tie game.

Welcome to “Rock, Paper, Scissors”.

What is your move? paper

Human plays paper. The computer plays rock.

Human wins.

  1. Zip the folder containing your two source code files (only .java files are there). Name your zip file program5.zip. Upload the file to Canvas. It is OK if Canvas modifies your filename.

Below is a short method that returns a random month. Use this to help you think about how to randomly return rock, paper, or scissors.

CSE PROGRAM #5 Solution
$30.00 $24.00