ITEC 120
L03b: More conditionals

Objectives

To successfully complete this lab you will develop programs that make decisions based on conditions specified in SWITCH statements.

Assignment

Create a workspace for the L03b lab. Create a java file called Merch.java with a main method, where you will do the work for this lab.

You will write a program that will ask the user what kind of merchandise they'd like to order. The band the Sockrockers have some merchandise to sell. You'll write a program that will offer merchandise to the user, prepare an order and price for the merchandise they'd like to purchase.

The Sockrockers are selling T-shirts, hats, and, of course, socks with their logo.

T-shirts come in S, M, and L. They come in white, black, orange, and green. They have 4 styles: shortsleeve ($15), tank ($12), long sleeve ($20), and hoodie ($22).

Hats are one size, cost $15, and come in white, black, and orange.

There are three types of Sockrockers socks: Children's socks for $6, Adult's white gym socks for $8, and the special commemorative 10th anniversary Sockrocker's orange socks for $10.

Due to limited supplies, a fan can order up to 1 T-shirt, 1 hat, and 1 pair of socks.

A sample run of this program might look like this (user input is in red):

Would you like a Sockrockers T-shirt today? (Y or N) Y
Small, medium, or large? (S, M or L) : M
There are 4 styles:
  T : tank
  S : short sleeve
  L : long sleeve
  H : hoodie
Which style would you like ? L

There are 4 colors:
  W : white
  B : black 
  O : orange 
  G : green
Which color would you like ? G

Would you like a Sockrockers hat today? (Y or N) N

Would you like Sockrockers socks today? (Y or N) Y

There are three kinds of socks: 
  C : Children's socks
  W : Adult's white gym socks 
  O : Adult's 10th anniversary orange socks 
Which kind? O

Here's your order:
Medium long-sleeve green T-shirt for $20  
10th anniversary socks for $10 
Your total is $30. 

Another sample run might look like this (user input is in red):

Would you like a Sockrockers T-shirt today? (Y or N) N

Would you like a Sockrockers hat today? (Y or N) Y

There are three colors of hats: 
  W : White
  B : Black
  O : Orange  
Which color? O

Would you like Sockrockers socks today? (Y or N) N

Here's your order:
Orange hat for $15  
Your total is $15. 

Helpful Hints

You could write this program entirely with IF statements, however, you will find the switch statement handy for many parts of this program.

This may seem like a large and confusing problem at first. Break it down into smaller pieces. For instance, code the hats part only. Get that part completely working and test it before adding another type of merchandise. The t-shirts are the most complicated piece of merchandise because they have size, color, and style. When you work on the t-shirt section, get one part working before adding the next part. This way, you limit the number of things you need to think about at once. After t-shirts, hats, and socks are all working, you can add in the code that calculates and prints the totals for the order.

Testing

You want to make sure your program works for all possible scenarios. When you think you are done, test your program. Try ordering all types of T-shirts, hats, and socks. Make sure the total price is correct. Your program should work for uppercase and lowercase letters. The user should be able to say "No" to all three questions.

Submit Your Assignment

Submit your Merch.java to the L03b dropbox on D2L.