Vinnie,
Try this out. Please note the "//***
" structure for
anywhere I made changes, and why. I hope this helps.
---
using System;
namespace IceCreamConeExceptionDemo.cs
{
class IceCreamCone
{
[STAThread]
static void Main(string[] args)
{
string[] IceCreamFlavor = new string[5];
IceCreamFlavor[0] = "vanilla";
IceCreamFlavor[1] = "chocolate";
IceCreamFlavor[2] = "strawberry";
IceCreamFlavor[3] = "peach";
IceCreamFlavor[4] = "banana";
int scoops;
scoops = 3;
int result;
int max;
char response;
max = 3;
Console.WriteLine("Pick a flavor, 0 = vanella, 1 =
chocolate, 2 =
strawberry");
Console.WriteLine("3 = peach, 4 = banana");
response = GetChar();
try
{
Console.WriteLine("Pick another",
IceCreamFlavor.Length);
//*** I commented this, as it was doing nothing.
//Console.Read();
response = GetChar();
}
catch (FormatException e)
{
throw (e);
}
Console.WriteLine("How many scoops");
++scoops;
response = GetChar();
if (response == scoops + max)
{
Console.WriteLine("Thank you for your
order");
//*** I added the blank read line to allow
//*** the application to stay open for review.
//*** This will force you to press enter to exit.
Console.ReadLine();
}
else
{
Console.Write("Re-enter amount of scoops");
++scoops;
result = scoops / max;
}
}
public static Char GetChar()
{
string inputString;
inputString = Console.ReadLine();
char response;
//*** I made sure that the response would
//*** only be the first character.
response = Convert.ToChar(inputString[0]);
return response;
}
public static void GetFlavor()
{
string[] IceCreamFlavor = new string[5];
IceCreamFlavor[0] = "vanilla";
IceCreamFlavor[1] = "chocolate";
IceCreamFlavor[2] = "strawberry";
IceCreamFlavor[3] = "peach";
IceCreamFlavor[4] = "banana";
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharp googlegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribe googlegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---
|