Note that there are some explanatory texts on larger screens.

plurals
  1. POValidate input and repeat input if it was invalid
    primarykey
    data
    text
    <p>Using Visual Studio, its an exercise, I need to add other students in, which isn't a problem. My main question is: I want the code to jump back to the input question if the value is above 100 or below 0 included, but I don't know the code that checks(validates) the user-input, any help would be very helpful and I would be incredibly grateful.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Student_Marks_For_Statement { class Program { static void Main(string[] args) { char moreData; double total = 0; double secondTotal = 0; for (double student1 = 0; student1 == 0; student1++) { Console.Write("Enter mark for student 1: "); student1 = Convert.ToDouble(Console.ReadLine()); total += student1; Console.WriteLine("Any more data? Enter 'y' or 'n' then return"); moreData = Convert.ToChar(Console.ReadLine()); if (moreData == 'n') { ; } if (moreData == 'y') { Console.Write("Enter Value :"); secondTotal = Convert.ToDouble(Console.ReadLine()); total += secondTotal; } for (double student2 = 0; student2 == 0; student2++) { Console.Write("Enter mark for student 2: "); student2 = Convert.ToDouble(Console.ReadLine()); total += student2; student2++; Console.WriteLine("Any more data? Enter 'y' or 'n' then return"); moreData = Convert.ToChar(Console.ReadLine()); if (moreData == 'n') { ; } if (moreData == 'y') { Console.Write("Enter Value :"); secondTotal = Convert.ToDouble(Console.ReadLine()); total += secondTotal; student2++; } Console.WriteLine("Total marks = : {0}", total); } } } } } </code></pre>
    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