Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions