0

whats the problem? sometimes when i supose to win (i write rock and the system did scissors) it says that i lost...

import java.util.Scanner; import java.util.Random; public class Program { public static void main(String[] args) { Scanner scan = new Scanner (System.in); String a = scan.nextLine(); a = a.substring (0, 1).toUpperCase() + a.substring (1); //makes the first letter of what you wrote to a capital letter. Random rand = new Random(); String[] three = {"Rock", "Paper", "Scissors"}; String choose = three [rand.nextInt (3)]; if (a.equals ("Rock")){ System.out.println ("You wrote: " + a); System.out.println ("System wrote : " + choose); }else if (a.equals ("Paper")){ System.out.println ("You wrote: " + a); System.out.println ("System wrote : " + choose); }else if (a.equals ("Scissors")){ System.out.println ("You wrote: " + a); System.out.println ("System wrote : " + choose); }else{ System.out.println ("ERROR - write only rock, paper or scissors! MAKE SURE YOU DONT PUT A SPACE AFTER WHAT YOU WRITE"); } if(a.equals("Rock") && three.equals("Scissors")){ System.out.println(""); System.out.println("You won!!!"); }else if(a.equals("Paper") && three.equals("Rock")){ System.out.println(""); System.out.println("You won!!!"); }else if(a.equals("Scissors") && three.equals("Paper")){ System.out.println(""); System.out.println("You won!!!"); }else if(a.equals("Rock") && three.equals("Rock")){ System.out.println(""); System.out.println("Its a draw!"); }else if(a.equals("Paper") && three.equals("Paper")){ System.out.println(""); System.out.println("Its a draw!"); }else if(a.equals("Scissors") && three.equals("Scissors")){ System.out.println(""); System.out.println("Its a draw!"); }else{ System.out.println(""); System.out.println("You lost!!!"); } } }

3rd May 2020, 2:43 PM
Yahel
Yahel - avatar
1 Answer
0
oh, my bad. thank you!
3rd May 2020, 3:57 PM
Yahel
Yahel - avatar