Question: Problem 2 You are writing a program that will total up all of your change. Create a Money class in the com.session.practice2 package. You will
Problem 2 You are writing a program that will total up all of your change. Create a Money class in the com.session.practice2 package. You will pass in the number of pennies, nickels, dimes, and quarters into the constructor. You can assume the numbes are zero or greater. There will be a method called getTotal which will display the total. It will add up all of the pennies, nickles, dimes, and quarters to determine how much money you have. Note: Keep in mind that a penny is 0.01 of a dollar, etc. The calculation of the total is as follows: numberOfPennies * 0.01 + numberOfNickles * 0.05 + numberOfDimes * 0.1 + numberOfQuarters * 0.25. Create a MoneyDemo class in the com day1.practice2 package. Read from the keyboard the number of pennies, nickles, dimes, and quarters. Display the total to the console. Class Outline: Money numberOfPennies int numberOfNickles:int numberOfDimes sint numberOfQuarters in Moneylint, int,int, int) o getNumberOfPennies) int getNumberOfNickles in get NumberOfDimesoint o getNumberOfQuarters() in getTotalo double Money Demo a main(Stringil) von Note: There are no setters in the Money class. Think about the limitations of implementing the class this way
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
