/java-test

Fun things and other challenges

Primary LanguageJava

Java Exercise

I have written this program using Spring boot and Maven.

To run the program you need to build it using maven and then just run the jars with parameters.

mvn clean verify

java -jar target/java-test-1.0-SNAPSHOT.jar apples apples apples apples apples apples milk 5

Stock Items

product unit cost
soup tin 0.65
bread loaf 0.80
milk bottle 1.30
apples single 0.10

Discounts

the offer valid from valid to
Buy 2 tins of soup and get a loaf of bread half cost yesterday for 7 days
Apples have a 10% discount from 3 days hence until the end of the following month

Inputs

All basket items added via the command prompt.

Outputs

All outputs must print to the command line.

Tests

  • Price a basket containing: 3 tins of soup and 2 loaves of bread, bought today,
    • Expected total cost = 3.15;
  • Price a basket containing: 6 apples and a bottle of milk, bought today,
    • Expected total cost = 1.90;
  • Price a basket containing: 6 apples and a bottle of milk, bought in 5 days time,
    • Expected total cost = 1.84;
  • Price a basket containing: 3 apples, 2 tins of soup and a loaf of bread, bought in 5 days time,
    • Expected total cost = 1.97.