switch statements

hi, I am trying to write a switch statement but I missed this lesson and have no clue how to write this. it looks easy but this is my first c++ course. ok here is what it says and here is what I have so far. Write a switch statement to print Nickel if the value of a variable coin is 5, Dime if the value is 10 and Quarter otherwise.

switch ( value )
{
value 5: cout << " Nickel" ;
break;
value 10: cout << "Dime";
break;
What trouble were you having?

You can read amount switch statements here:
http://www.cplusplus.com/doc/tutorial/control/#switch
Your "value"s should be cases.
1
2
3
4
5
6
7
8
9
10
11
switch (value)
{
case 5:
    cout << "Nickel";
    break;
case 10:
    cout << "Dime";
    break;
default: // For everything else (not 5 or 10)
    cout << "Quarter";
}
Topic archived. No new replies allowed.