작은 시네마 프로그램을 만들려고합니다. 사용자 나이에 따라 if 문을 설정하고 하나의 나이는 12A입니다. 즉, 그들이 동행하는지 묻지 않으면 안됩니다. 성인프로그램에서 부울 조건을 올바르게 설정하는 방법
Console.WriteLine(" Enter the number of the film you wish to see :");
int selection = int.Parse(Console.ReadLine());
Console.WriteLine("Enter your age:");
int age = int.Parse(Console.ReadLine());
bool yes = true;
bool no = false;
처음 두 옵션 i 이 있으면 모든 것이 원활하게 진행됩니다. 내가 문 경우 else
에 Console.ReadLine();
를 작성하는 경우가 도달 할 수없는 코드는 상관없이 내가 입력이 첫 번째 조건을 통해 이동이 종료됩니다 또는 여기
if (selection == 3)
{
if (age >= 12)
{
Console.WriteLine("You may enter");
}
else
{
{
Console.WriteLine("Are you accompanied by an adult? Answer yes or no");
Console.ReadLine();
if (true)
{
Console.WriteLine("You may pass.");
}
else if (false)
{
Console.WriteLine("You are not allowed.");
...
.
미리 도움을 청하십시오.
'다른 (거짓) {...}'들어갈 기회가 없으니, 다른 뜻인가요? '(true)'가 언제나 비가 오거나 내리면 –
"* 여기에 아무리 입력해도 첫 번째 조건부 *를 통과합니다." 물론 그것은 : Console.ReadLine();의 결과를 무시하고 항상 true 인'if (true)'를 가지게됩니다. –
@DavidArno 바로 가기! 본질적으로'if (true == true)' – EpicKip