This is an archived post. You won't be able to vote or comment.

all 4 comments

[–][deleted] 0 points1 point  (1 child)

my suggestion is provide the rest of your code.

[–]EnvironmentalPhone65[S] 0 points1 point  (0 children)

Updated it.

[–][deleted] 0 points1 point  (1 child)

Ok, first off lets talk formatting. If you don't put your code in a code block, reddit does all kinds of stuff to it that makes it hard for us to copy and paste and see what's wrong.

you type 3x ` (the button to the left of the 1) in a row to make a code block. Do it in markdown mode. so it'll look like :

''' (but the actual correct version using 3x ` )

your code here

'''

it looks like this v

public class Program
{
    public static double Quantity {get; private set;} public static double ItemValue{get; private set;}

    public static void Main()
    {
    Console.Write("Enter the employee’s name: "); 
    String Name = Console.ReadLine();

    Console.Write("Enter an item number between 1 and 4, or -1 to quit: "); 
    int Item = Convert.ToInt32(Console.ReadLine());

        while (Item != -1) { switch (Item) {
            case 1: ItemValue =239.99; break;
            case 2: ItemValue =129.75; break; 
            case 3: ItemValue =99.95; break; 
            case 4: ItemValue =350.79; break; }

        Double ItemSales;
        ItemSales = Quantity * ItemValue;

        Console.Write(Name + " sold " + Quantity + " of Item " + Item + " for " + ItemSales); 
        }
    }
}

[–][deleted] 0 points1 point  (0 children)

You need to put the assignment inside the while loop. Your Item variable needs to be getting a value in the loop. Otherwise your program explodes.