So, I'm in my third, almost fourth week of a C# course for college and this week we played around with Loops, I wrote a program for class (The topic was given out by the teacher and was the same for everyone). I think it turned out well, but after reading through some class mate's posts I'm wondering if it could have been better (Note, we're not aloud to use arrays, only simple loops). Because I notice alot of students complaining about having to use a lot of Break; Continue; statements in order to leave the loop. My program however didn't utilize any. I'll toss up source for input.
// ---------------------------------------------------------------
// Programming Assignment: LAB3A
// Developer: MP
// Date Written: November 18, 2012
// Purpose: Diver's Score Calculator
// ---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LAB3A
{
class Program
{
static void Main(string[] args)
{
do
{
//vars
double rating, score, scoreTotal = 0, highScore = 0, lowScore = 10, dedScore = 0;
string dName, dHome;
//Prompt for name/city/rating
Console.Write("Diver's Name: ");
dName = Console.ReadLine();
Console.Write("Diver's City: ");
dHome = Console.ReadLine();
//rating stuff
Console.Write("Dive degree of difficulty: ");
rating = Double.Parse(Console.ReadLine());
while (rating < 1 || rating > 1.67)
{
Console.WriteLine("Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)");
Console.Write("Dive degree of difficulty: ");
rating = Double.Parse(Console.ReadLine());
}
//Judge Scoring
for (int i = 1; i <= 5; i++)
{
Console.WriteLine("Judge #{0} score: ", i);
score = Double.Parse(Console.ReadLine());
while (score < 0 || score > 10)
{
Console.WriteLine("Invalid score - Please reenter (Valid Range: 0 - 10)");
Console.WriteLine("Judge #{0} score: ", i);
score = Double.Parse(Console.ReadLine());
}
if (score > highScore)
{
highScore = score;
}
if (score < lowScore)
{
lowScore = score;
}
scoreTotal = score + scoreTotal;
}
dedScore = highScore + lowScore;
scoreTotal = (scoreTotal - dedScore) / 3 * rating;
//Display stuffs
Console.WriteLine("Diver: {0}", dName);
Console.WriteLine("City: {0}", dHome);
Console.WriteLine("Dive Score: {0}", scoreTotal);
Console.WriteLine("Do you want to process another diver (Y/N)?");
} while (Console.ReadLine().ToUpper() != "N");
break;
}
}
}