Advertisement
AvengersAssemble

Untitled

Sep 4th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace MarksAvgCalculator
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double marksTotal = 0;
  14.             int i = 0;
  15.             string exit = "no";
  16.             while (exit != "true")
  17.             {
  18.                 i++;
  19.                 Console.WriteLine("Please enter mark:");
  20.                 double mark = double.Parse(Console.ReadLine());
  21.                 marksTotal += mark;
  22.                 Console.WriteLine("Would you like to insert another mark?");
  23.                 Console.WriteLine("y/n");
  24.                 string yN = Console.ReadLine();
  25.                 if (yN == "y")
  26.                     Console.WriteLine();
  27.                 else if (yN == "n")
  28.                 {
  29.                     Console.WriteLine();
  30.                     exit = "true";
  31.                 }
  32.                 else
  33.                     Console.WriteLine("Invalid choice.");
  34.                 Console.WriteLine();
  35.             }
  36.             Console.WriteLine("grades average is " + marksTotal / i);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement