Modify the Money class that is provided. This is a simple class that stores money as dollars and cents. For example, $12

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Modify the Money class that is provided. This is a simple class that stores money as dollars and cents. For example, $12

Post by answerhappygod »

Modify The Money Class That Is Provided This Is A Simple Class That Stores Money As Dollars And Cents For Example 12 1
Modify The Money Class That Is Provided This Is A Simple Class That Stores Money As Dollars And Cents For Example 12 1 (56.93 KiB) Viewed 32 times
Modify the Money class that is provided. This is a simple class that stores money as dollars and cents. For example, $12.73 will be stored as 12 dollars and 73 cents. The cents value stored should never be greater than 99 , so 3 dollars and 164 cents should be stored as 4 dollars and 64 cents. The class has only one method, toString (), which returns a String representation of the money object. Your first task is to create THREE constructors for the class as follows: public Money() {…} // creates a Money object with zero money public Money (int dollars, int cents) {…} // creates a Money object with total value as specified by // the input values. Input values are assumed to satisfy // dollars >=0 and cents >=0. // will always have 0<= cents <=99) public Money (int cents) {…} // creates a Money object with value as specified by / the input cents. Input value is assumed to satisfy // cents >=0 // will always have 0<= cents <=99) In all the constructors, be sure that the internal state (dollars and cents) represents the total money and that cents is not greater than 99 . The Money class has a toStringl ) method to help test/debug your code. It returns a String representation of the money object.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply