Using the correct loop for incorrect input
<p>I am trying to enter a loop to stop the number of areas being below 0 or above 5, I've tried entering a do while loop, but it still executes the next block of code even when incorrect input has been entered. I've commented the section with the loop. Help would be much appreciated, thank you.</p>

<pre><code>const int MaxItems = 5; // max size of array needed 
double[] itemCosts = new double[MaxItems];
int jobType; // valid values are 1=normal, 2=waterproofing, 3=skim 
int nAreas;
int i;
string customer;
double totalCost = 0.0;
double averageCost;
const double discountPrice = 800; // price at which discount available 
const double discountRate = 0.1; // discount rate 
const double setupCostPerArea = 30.00;

// cost of moving furniture, carpets etc.     

double discount, discountedTotal; // discount amount and discounted total 
double width, height; // width and height of plaster area 
double[] basePrices = { 0, 35.0, 30.0, 20.0 };  // added 0 as index placeholder, so 35 can be selected using 1, and so forth.
// prices per square metre for standard, plasterboard and skim, and skim only 

Console.Write("enter name of customer: ");
customer = Console.ReadLine();

Console.Write("enter number of plaster areas to quote for: ");
nAreas = Convert.ToInt32(Console.ReadLine());

do
{
    Console.WriteLine("Please Enter numbers of rooms between 1 and 5 only!!!!");
} while (nAreas &lt; 1 &amp;&amp; nAreas &gt; 5); // loop

for (i = 0; i &lt; nAreas; i++)
{
    Console.WriteLine("Data entry for area {0}", i + 1);

    Console.Write("enter 1 (standard), 2 (plasterboard and skim) or 3 (skim only): ");
    jobType = Convert.ToInt32(Console.ReadLine());

    Console.Write("enter width of area {0} in metres: ", i + 1);
    width = Convert.ToDouble(Console.ReadLine());

    Console.Write("enter height of area {0} in metres: ", i + 1);
    height = Convert.ToDouble(Console.ReadLine());

    // add base area cost to price based on area and type of plaster 
    itemCosts[i] = setupCostPerArea + (basePrices[jobType] * (width * height));
    totalCost += itemCosts[i];
}

averageCost = totalCost / nAreas;

// main report heading 
Console.WriteLine("\n");
Console.WriteLine("Plasterers R US Job Costing Report");
Console.WriteLine("===================================");
Console.WriteLine("\nName of customer: {0}\n", customer);
Console.WriteLine("No. of plaster areas: {0}", nAreas);
Console.WriteLine("Average Cost per area £{0:0.00}", averageCost);
// output subheadings 
Console.WriteLine("Area\tCost\tDifference From Average");
for (i = 0; i &lt; nAreas; i++)
{
    Console.Write("{0}\t", i + 1);
    Console.Write("£{0:0.00}\t", itemCosts[i]);
    Console.WriteLine("£{0:0.00}", itemCosts[i] - averageCost);
}
Console.WriteLine("Total Cost £{0:0.00}", totalCost);
if (totalCost &gt; discountPrice)
{
    discount = totalCost * discountRate;
    discountedTotal = totalCost - discount;
    Console.WriteLine(" - Discount of £{0:0.00}", discount);
    Console.WriteLine(" Discounted Total £{0:0.00}", discountedTotal);
}

Console.WriteLine("press enter to continue");
Console.ReadLine();
</code></pre>
