게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
C#))본삭금))이거 else if명령문 쓰는데 왜 자꾸 에러가 날까요?
게시물ID : programmer_19820짧은주소 복사하기
작성자 : 멕시카불라
추천 : 0
조회수 : 654회
댓글수 : 6개
등록시간 : 2017/02/20 11:12:34
옵션
  • 베스트금지
  • 베오베금지
  • 본인삭제금지
  • 외부펌금지
//loop
            while (playercash > 0)
            {
                Console.WriteLine(" Dealer: How much you want to bet on? By the way, you have $200.");
                Console.WriteLine("");
                int playerbet = int.Parse(Console.ReadLine());
                Console.WriteLine("");
                Console.WriteLine(" Dealer: You bet $" + playerbet + " on this game.");
                Console.ReadKey();


                Console.WriteLine(" Dealer: You have 5 choices!");
                Console.ReadKey();
                Console.WriteLine("\n1 = Small \t2 = Big \n3 = Odd \t4 = Even \n5 = Triples");
                Console.ReadKey();
                Console.WriteLine(" Dealer: Which one that you want to bet on?");
                string playerchoice = Console.ReadLine();

                //If

                if (playerchoice == "1" || playerchoice == "small")
                {
                    //Show name
                    Console.ReadKey();
                    Console.WriteLine(" Dealer: You chose Small!");
                    Console.WriteLine("");

                    Console.ReadKey();
                    Console.WriteLine("Rolling Dice..");
                    Console.WriteLine("");
                    Console.ReadKey();

                    //Print the numbers that were stored
                    Console.WriteLine("Dice 1: " + dice1);
                    Console.WriteLine("Dice 2: " + dice2);
                    Console.WriteLine("Dice 3: " + dice3);
                    Console.WriteLine("");
                    Console.WriteLine("Total = " + total);

                    if (total < 11) ;
                    {
                        Console.WriteLine("");
                        Console.ReadKey();
                        Console.WriteLine("You Win!");
                        playercash = playerbet + playercash;
                        Console.WriteLine("You just earned $" + playerbet + "!!");
                        Console.WriteLine("Now you have $" + playercash + "!!!");
                    }
                    if (total > 10) ;
                    {
                        Console.WriteLine("");
                        Console.ReadKey();
                        Console.WriteLine("You Lose!");
                        playercash = playerbet - playercash;
                        Console.WriteLine("You just lost $" + playerbet + "!!");
                        Console.WriteLine("Now you have $" + playercash + "!!!");
                    }


                }

            }


저렇게하면 total이 10 이상일때 lose가 안뜨고
마지막 if 절을 else if 절로 바꾸면 


error.png


저렇게 에러가 납니다.

if, else if 둘다 if (playerchoice == "1" || playerchoice == "small") 안에 들어가야하는 애들인데 
에러가 else if 위에 닫는 } 입력해서 else if 는 if (playerchoice == "1" || playerchoice == "small") 밖으로 나가는 else if 절로 만들더라고요
어떻게 해결해야하나요??
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호