using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Practical_1_Q16_Calculate_Average { class Program { static void Main(string[] args) { double total = 0; int count = 0; double score = 5; Console.WriteLine("Enter a score (0-100): "); score = double.Parse(Console.ReadLine()); while (score < 0 || score > 100) { Console.WriteLine("Invalid, must be 0-100"); score = double.Parse(Console.ReadLine()); total += score; count++; } if (count == 0) { Console.WriteLine("No numbers were entered."); } else { Console.WriteLine("Average:" + total / count); } Console.WriteLine(""); Console.WriteLine("Program finished"); Console.ReadLine(); } } }
while
true
do { score = get_from_user(); if ( score >= 0 && score <=100) { update_and_possibly_print_values(); } } while (score != -1);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)