Skip to content

This is my solution of how I approached the problem. It is a Maven project with lombok dependency. Unit tests are missing but some UAT tests have been carried out.

Notifications You must be signed in to change notification settings

danielPoloWork/EURIS-academy2022-exam-javaCore-part2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EURIS Academy 2022

Java Core Exam Part 1

OldFashionPound

A library (package OldFashionPound) implementing the 4 arithmetic operations (sum, subtraction, multiplication and division) for pre-1970 UK prices.

Under the old money system of UK, before 1970, there were 12 pence in a shilling and 20 shillings, or 240 pence, in a pound. Thus, a price in th OldUK Money system was expressed in Pounds, Shillings and Pence.

For example "12p 6s 10d" is 12 Pounds, 6 Shillings and 10 Pence.

Sum and Subtraction should add or subtract two prices respectively.

Example SUM:

  • 5p 17s 8d + 3p 4s 10d = 9p 2s 6d

Example SUBTRACTION:

  • 5p 17s 8d - 3p 4s 10d = 2p 12s 10d

Subtractions giving negative results are managed:

  • 5p 17s 8d - 5p 18s 8d = 0d (-1s 0d)

Multiplication and division will multiply or divide a price by an integer

Example MULTIPLICATION:

  • 5p 17s 8d * 2 = 11p 15s 4d

Example DIVISION:

  • 5p 17s 8d / 3 = 1p 19s 2d (2d)

Another Example DIVISION

  • 18p 16s 1d / 15 = 1p 5s 0d (1s 1d)

Usage

$ java -jar path/to/OldFashionPound-X.X.X.jar [expression]

Expression must follow one of this rule:

  • Xp Ys Zd [+|-] Ap Bs Cd
  • Xp Ys Zd [*|/] K

Edit configurations -> set Program arguments

 "5p 17s 8d [+] 3p 4s 10d"
 "5p 17s 8d [-] 3p 4s 10d"
 "5p 17s 8d [-] 5p 18s 8d"
 "5p 17s 8d [*] 2"
 "5p 17s 8d [/] 3"
 "18p 16s 1d [/] 15"

About

This is my solution of how I approached the problem. It is a Maven project with lombok dependency. Unit tests are missing but some UAT tests have been carried out.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages