Write the dry run of the following program ( Java-OOP) Define a class named Money whose objects represent amounts of U.S. money. The class should have two instance variables of type int for the dollars and cents in the amount of money. Include a constructor with two parameters of type int for the dollars and cents, one with one constructor of type int for an amount of dollars with zero cents, and a no-argument constructor. Include the methods add and minus for addition and subtraction of amounts of money. These methods should be static methods, should each have two parameters of type Money, and return a value of type Money. Include a reasonable set of accessor and mutator methods as well as the methods equals and toString. Write a test program for your class. Part Two: Add a second version of the methods for addition and subtraction. These methods should have the same names as the static version but should use a calling object and a single argument. For example, this version of the add method (for addition) has a calling object and one argument. So m1.add(m2) returns the result of adding the Money objects m1 and m2 Note that your class should have all these methods; for example, there should be two methods named add. Alternate Part Two: Add a second version of the methods for addition and subtraction. These methods should have the same names as the static version but should use a calling object and a single argument. The methods should be void methods. The result should be given as the changed value of the calling object. For example, this version of the add method (for addition) has a calling object and one argument. Therefore, m1.add(m2); changes the values of the instance variables of m1 so they represent the result of adding m2 to the original version of m1 Note that your class should have all these methods; for example, there should be two methods named add.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write the dry run of the following program ( Java-OOP) Define a class named Money whose objects represent amounts of U.S. money. The class should have two instance variables of type int for the dollars and cents in the amount of money. Include a constructor with two parameters of type int for the dollars and cents, one with one constructor of type int for an amount of dollars with zero cents, and a no-argument constructor. Include the methods add and minus for addition and subtraction of amounts of money. These methods should be static methods, should each have two parameters of type Money, and return a value of type Money. Include a reasonable set of accessor and mutator methods as well as the methods equals and toString. Write a test program for your class. Part Two: Add a second version of the methods for addition and subtraction. These methods should have the same names as the static version but should use a calling object and a single argument. For example, this version of the add method (for addition) has a calling object and one argument. So m1.add(m2) returns the result of adding the Money objects m1 and m2 Note that your class should have all these methods; for example, there should be two methods named add. Alternate Part Two: Add a second version of the methods for addition and subtraction. These methods should have the same names as the static version but should use a calling object and a single argument. The methods should be void methods. The result should be given as the changed value of the calling object. For example, this version of the add method (for addition) has a calling object and one argument. Therefore, m1.add(m2); changes the values of the instance variables of m1 so they represent the result of adding m2 to the original version of m1 Note that your class should have all these methods; for example, there should be two methods named add.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY