Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Issue: program terminates itself when it shouldn't
    primarykey
    data
    text
    <p>I'm making a C# console application for my college course and I've got an issue where I (or anybody else on the course) don't know what's wrong. In fact the tutor's not sure why it's happening. I'll show you part of the code to see if anyone can help. Probably a good idea to mention that I'm new to C# and programming in general. </p> <pre><code> static void Main(string[] args) { string userName = GetName(); int gradelevel = level(); double random1 = 0; double random2 = 0; int userChoice = menu(); int numberofquestions = 0; string Message; int userScore = 0; do { if ((gradelevel == 1) &amp;&amp; (userChoice == 1))//ADDITION LEVEL 1 { generateSingleDigit(ref random1, ref random2); double userAnswer = additionQuestion(ref random1, ref random2); double Correctanswer = random1 + random2; Message = checkAnswer(userAnswer, Correctanswer); if (userAnswer == Correctanswer) { generatePositiveResponse(); userScore++; } else { int numberofAttempts = 1; do { generateNegativeResponse(); userAnswer = additionQuestion(ref random1, ref random2); Message = checkAnswer(userAnswer, Correctanswer); numberofAttempts++; } while ((numberofAttempts &lt; 3) &amp;&amp; (Message == "Incorrect")); Console.WriteLine("The correct answer is {0}", Correctanswer); } } numberofquestions++; } while (numberofquestions &lt;= 9); percentage(ref userScore); ` </code></pre> <p>The issue I'm having is that once the user has completed the 10 questions, the results from the percentage method briefly flash up and then the application closes itself. No "Press any key to continue" that I've seen in other applications I've made. </p> <p>I would really appreciate any help on this. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload