Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. char vehicle; //will represent the vehicle that goes into the told
  2.  
  3. //for future reference: 'c' for car, 't' for truck, 'b' for bike
  4.  
  5. //lets say our vehicle is a truck
  6. vehicle = 't'; //we have to use single quotes since it's a char
  7.  
  8. //pass the vehicle into a switch
  9. //switch will compare vehicle with the chars in the cases, then do that case
  10. switch (vehicle){
  11.     case 'c':
  12.         System.out.println("car price goes here");
  13.         break;
  14.     case 't':
  15.         System.out.println("truck price goes here");
  16.         break;
  17.     case 'b':
  18.         System.out.println("truck price goes here");
  19.         break;
  20.     default:
  21.         break;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement