Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char vehicle; //will represent the vehicle that goes into the told
- //for future reference: 'c' for car, 't' for truck, 'b' for bike
- //lets say our vehicle is a truck
- vehicle = 't'; //we have to use single quotes since it's a char
- //pass the vehicle into a switch
- //switch will compare vehicle with the chars in the cases, then do that case
- switch (vehicle){
- case 'c':
- System.out.println("car price goes here");
- break;
- case 't':
- System.out.println("truck price goes here");
- break;
- case 'b':
- System.out.println("truck price goes here");
- break;
- default:
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement