Программа выполняется но случай переключения не рассматривается я имею в виду что он вообще не выполняется
import java.util.*; public class playing_rock_paper_scissors_against_computer{ public void main(){ Scanner in=new Scanner(System.in); System.out.println( "please choose difficulty level 'H' for hard, 'M' for medium and 'E' for easy"); char lev=in.next().charAt(0); System.out.println("OK"); System.out.println("so lets start ROOOOOCK,PAAAAPER,SCISSORS"); String ch=in.next(); double n=Math.random(); String str; switch(lev){ case 'H': if(ch=="rock"){ if(n>=0.41&&n<=0.9){ System.out.println("Paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose an easier level next time"); } if(n>=0.31&&n<=0.4){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } } if(ch=="paper"){ if(n>=0.41&&n<=0.9){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose an easier level next time"); } if(n>=0.31&&n<=0.4){ System.out.println("Paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } else{ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose an easier level next time"); } } if(ch=="scissors"){ if(n>=0.41&&n<=0.9){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose an easier level next time"); } if(n>=0.31&&n<=0.4){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } else{ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose an easier level next time"); } } case 'M': if(ch=="rock"){ if(n>=0.61&&n<=0.9){ System.out.println("Paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose level easy next time"); } if(n>=0.31&&n<=0.6){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } else{ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } } if(ch=="paper"){ if(n>=0.61&&n<=0.9){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose level easy next time"); } if(n>=0.31&&n<=0.6){ System.out.println("Paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.31){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } else{ System.out.println("Paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } } if(ch=="scissors"){ if(n>=0.61&&n<=0.9){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); System.out.println("choose level easy next time"); } if(n>=0.31&&n<=0.6){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } else{ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } } case 'E': if(ch=="rock"){ if(n>=0.41&&n<=0.9){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } if(n>=0.31&&n<=0.4){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); } else{ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } } if(ch=="paper"){ if(n>=0.41&&n<=0.9){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } if(n>=0.31&&n<=0.4){ System.out.println("paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); } else{ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } } if(ch=="scissors"){ if(n>=0.41&&n<=0.9){ System.out.println("paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } if(n>=0.31&&n<=0.4){ System.out.println("scissors"); str="scissors"; System.out.println("computer puts"+str); System.out.println("Unfortunately it is a draw"); } if(n>=0.0&&n<=0.3){ System.out.println("rock"); str="rock"; System.out.println("computer puts"+str); System.out.println("user loses please try again"); System.out.println("computer wins"); } else{ System.out.println("paper"); str="paper"; System.out.println("computer puts"+str); System.out.println("User wins yayee!!!!"); } } } System.out.println("thanks for playing the game"); }}
Что я уже пробовал:
Я пробовал выполнять,но он просто принимает входные данные до тех пор, пока камень, ножницы или бумага не покинут переключатель и не напечатают непосредственно последнее утверждение
W∴ Balboos, GHB
Вряд ли кто - то прочтет ваш список-тем более, что вы даже не намекаете, где это пошло не так. Переформулируйте вопрос так, чтобы проблема была выделена, а не скрыта.
Member 13754804
можете ли вы теперь проверить пожалуйста я изменил вопрос
OriginalGriff
Измененные теги на Java - Javascript-это совершенно другой язык и среда.