Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Approximating %u03C0) %u03C0 can computed using the following formula: %u03A0 =

ID: 3536645 • Letter: #

Question

(Approximating %u03C0) %u03C0 can computed using the following formula:

%u03A0 = 4 x(1-1/3 + 1/5 - 1/7 + 1/9 %u2013 1/11 + 1/13 +%u2026)

Write a program that displays the result the of 4 x(1-1/3 + 1/5 -1/7 + 1/9 -1/11 +1/13). Use 1.0 instead of 1 in your program

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(Game: scissor, rock, paper) Write a program that plays the popular scissor-rock-paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Here are sample runs:

http://www.mathjax.org/help/configuration

Explanation / Answer

import java.util.Scanner;
import java.util.Random;

public class Game2play
{
public static void main( String[] args )
{
String result = " ", symbola = " ", symbolb=" ";
Scanner kbinput = new Scanner(System.in);
System.out.print("Scissors(0), rock(1), paper(2): ");

int choice = kbinput.nextInt();

Random random = new Random();

int pick = random.nextInt(3);
if (choice == pick)
result = "It's a tie!";
else
{
if (((choice == 0) && (pick == 2)) || ((choice ==1) && (pick == 0)) || ((choice == 2) && (pick==1)))
result = "You won!";
else
result = "You lose!";
}

if (pick == 0)
symbola = "Scissor";
if (choice == 0)
symbolb = "Scissor";

if (pick == 1)
symbola = "Rock!";

if (pick == 1)
symbola = "Rock!";
if (choice == 1)
symbolb ="Rock!";

if(pick ==2)
symbola = "Paper!";
if (choice == 2)
symbolb = "Paper!";

System.out.println(" OMG! The computer is " + symbola + "! You are " + symbolb + "! OMG! " + result);
}
}


/****************************************
Here are sample runs:
scissor (0), rock (1), paper (2): 1
The computer is scissor. You are rock. You won

scissor (0), rock (1), paper (2): 2
The computer is paper. You are paper too. It is a draw