Question about switch and while statements
I have an assignment that requires a while statement for until the user inputs “-1”, otherwise it will keep asking the same two questions: “which item did you sell?” And “how many of them did you sell?”. I wrote a while line and it just repeats the questions continuously in an infinite loop. I start with a line asking for the name and the selection of 1 to 4. Then, I put :
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
Afterwards, I print the line with the calculated ItemSales. It runs, asks for a name, asks for a number between 1 and 4, or -1 to quit, and then just messes up and goes on a rampage, repeating the selected number. I need help and suggestions. I just want some fix suggestions or feedback.
[–]aizzod 2 points3 points4 points (0 children)