Sep 2006 IPSE Homework assignment 2

A broker in cookies makes his week planning. Every day, except Sunday, fresh boxes of cookies are delivered to his warehouse. There are three cookie suppliers, each of which have different pricing policies. The broker decides in advance which supplier to use for a week. The pricing policies of the suppliers are as follows.


Write a Java program that does the following. It reads 6 integral numbers representing the numbers of boxes needed for each day of the week. Then it reads the code of a supplier and it prints the total cost for that week when that supplier will be used. If the supplier is WaffleBaffle, the name on input is followed by a double representing the world market price of coffee.


Input is on standard in ( It consists of 6 integral numbers followed by the word "CM" or "V" or by the word "WB" and a double. The numbers and words are separated by whitespace (one or more spaces, newlines, tabs).


Output should be written to standard out (System.out). The format is:

cost using [supplier code]: ... euro
On the dots the right value should appear.

Implementation and design



20 10 8 7 6 30 V


week cost using V: 396.0 euro


20 10 8 7 6 30
WB 3.5


week cost using WB: 448.05 euro