I'm new to Java, and my teacher keeps changing up the directions for creating the game rock, paper scissors.
she wants us to include a do while loop today. she wants us to use the switch statement as well, but I am not sure if I have the do while loop in the correct place, I keep getting errors. I would be so grate ful if someone would help me figure out what I am doing wrong.
import javax.swing.JOptionPane;
public class Option{
public static void main(String [] args){
int userChoice;
int compChoice;
int win,loses,draws;
int games;
do{
computer =(int)Math.random ()*3)+1;
user = JOptionPane.showInputDialog(null, "enter a number 0 to 2");
}
switch (option){
case 1: JoptionPane.showInputDialog(null, "Play paper,rock, scissors,against the computer");
if ( rock == 0 && rock == 0){
lose--;
JOptionPane.showMessageDialog(null, "The game is a draw");
}
else if (rock ==0 && scisssors ==2){
lose--;
JOptionPane.showMessageDialog(null," Rock win + lose");
}
if (paper == 1 && rock == 0){
win++;
JOptionPane.showMessageDialog(null,"Paper wint + win");
}
else if (scissors ==2 && paper ==1){
win++;
JOptionPane.showMessageDialog(null,"scissors win + win");
}
if (rock == 0 && paper ==1){
lose--;
JOptionPane.showMessageDialog(null ,"paper wins + lose");
}
else if (scissors==2 && rock ==0){
JOptionPane.showMessageDialog(null, "Rock win + lose");
lose--;
{
if (paper ==1 && scissors ==2){
win++;
JOptionPane.showMessageDialog(null, "scissors win +win");
}
else if (paper ==1 && paper ==1){
JOptionPane.showMessageDialog(null,"The game is a draw");
}
break;
case2: JOptionPane.showMessageDialog(null,"Print out the statistics versus the computer");
break;
case3: JOptionPane.showMessageDialog(null,"Quit the program");
break;
default: JOptionPane.showMessageDialog (null,"Errors: invalid status");
System.exit (0);
}
while {(choice>1 && choice<3)
}

New Topic/Question
Reply




MultiQuote






|