Program using basic beginners JAVA.. (*no use of while loops*) In predecimalization Britain, a British pound was divided into 20 shillings, and a shilling was
Program using basic beginners JAVA.. (*no use of while loops*)
In "predecimalization" Britain, a British pound was divided into 20 shillings, and a shilling was divided into 12 pence ("pence" being their plural of "penny"). For lunch one day, Jack decides to have a steak and kidney pie and beer. Write a program to determine the change Jack will receive from having a pie and pint. Your program should ask for the amount of money that Jack has, and for the price of the pie, and the price of the beer, each in pounds/shillings/pence amounts. Output the pounds/shillings/pence change Jack will receive. Your output should report as many pounds as possible, less than 20 shillings and less than 12 pence. You may assume that input for shillings will be less than 20, and that input for pence will be less than 12. You may also assume that the cost of the lunch will not exceed the amount of money Jack has.
The following is a sample execution:
Enter the pounds that Jack has: 4
Enter the shillings that Jack has: 10
Enter the pence that Jack has: 6
Enter the pounds for the pie: 1
Enter the shillings for the pie: 2
Enter the pence for the pie: 3
Enter the pounds for the beer: 1
Enter the shillings for the beer: 12
Enter the pence for the beer: 0
Jack's change is 1pounds 16shillings 3pence
Hint: convert everything to pence, figure out Jack's change, and then convert the change to pounds, shillings and pence. Grading Elements:
The program should Ask and use the amount of money Jack has in pounds, shillings and pence Ask and use the cost of a steak and kidney pie in pounds, shillings and pence Ask and use the cost of a pint of beer in pounds, shillings and pence Correctly calculate Jack's change Correctly display Jack's change in pounds, shillings and pence
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started