Edit this java code add the 3 amounts

Assignment Help Basic Computer Science
Reference no: EM13230428

Can anyone pls edit this Java code? I need to be able to add the 3 amounts listed on the main method public class Money { private Currency currency; private int wholenum; private int decnum; public Money(Currency currency, int wholenum, int decnum) { this.currency = currency; this.wholenum = wholenum; if (decnum > 99) this.wholenum = this.wholenum + decnum/100; this.decnum = decnum0; } public String toString() { if (decnum<10) return currency +" "+wholenum+".0"+decnum; return currency +" "+wholenum+"."+decnum; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (this.getClass() != obj.getClass()) return false; Money M = (Money) obj; // casting obj to Money if (this.currency != M.currency) return false; if (this.wholenum != M.wholenum) return false; return (this.decnum == M.decnum); } public int hashCode() { Integer I = this.decnum; return I.toString().hashCode(); } // TESTING public static void main(String[] args) { Money M1 = new Money(Currency.PHP, 500, 1); Money M2 = new Money(Currency.PHP, 500, 1234); Money M3 = new Money(Currency.PHP, 500, 1234); System.out.println(M1 +" "+ M1.equals(M2) +" "+ M2); System.out.println(M2 +" "+ M2.equals(M2) +" "+ M2); System.out.println(M2 +" "+ M2.equals(M3) +" "+ M3); System.out.println(M1 +" "+ M1.hashCode()); System.out.println(M2 +" "+ M2.hashCode()); System.out.println(M3 +" "+ M3.hashCode()); }

Reference no: EM13230428

Questions Cloud

How many units should emerson order for the coming holiday : How many units should Emerson order for the coming holiday season?
What is its default risk premium : An 8-year corporate bond has a yield of 8.3%, which includes a liquidity premium of 0.75%. What is its default risk premium?
Examine each of the cells and write a brief statement : Assume that a security model is needed for the protection of information in your class. Using the CNSS model, examine each of the cells and write a brief statement on how you would addess the component represented in that cell.
How to implement a turnaround strategy : Can someone give me some ideas of how to implement a turnaround strategy for a United Way dued to the fact that they have some ethcial problems and increase of competitve.
Edit this java code add the 3 amounts : Can anyone pls edit this Java code? I need to be able to add the 3 amounts listed on the main method public class Money { private Currency currency; private int wholenum; private int decnum; public Money(Currency currency, int wholenum, int decnum..
Calculate the degree of completion of the reaction : A gaseous mixture containing 50 mol% hydrogen and 50 mol% acetaldehyde (C2H4O) is initially contained in a rigid container at a total pressure of 760 mmHg absolute. The formation of ethanol occurs according to C2H4O + H2 C2H6O.
What is function of enable control input of tri-state buffer : What is the function of the enable control input of a tri-state buffer If the output of two or more tri-state buffers is connected to each other, what is the restriction on enable control input lines What does happen when this restriction is viola..
What activities would be included in the value added time : What activities would be included in the value added time of fast food hamburger preparation and delivery? Why are these part of the Value Added Time?
How many machines are required to meet the forecast : The standard time at Lensco Inc for grinding a set of prescription lenses is 18 minutes. If the typical efficiency for their operations is 80%, and typical machine reliability is 87% how many machines are required to meet the forecast of 17,247 le..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What are the practical benefits

What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.Socket)?

  Display the total sales with ah dollar sign

Display the total sales with ah dollar sign and two decimal places. I have no idea how to code this add button.The code has to work for Visual Basic. Thank you.

  Summarize the facts and ethical issues noted in the article

Summarize the facts and ethical issues noted in the article. Cite your source within the body of your initial post and provide a complete reference for the source, formatted according to APA style as outlines in the Ashford Writing Center, at the ..

  What is the duration of a particular type

A microprocessor is clocked at a rate of 8 GHz. a. How long is a clock cycle? 1/frequency=1/(8*10^9) b. What is the duration of a particular type of machine instruction consisting of six clock cycles?

  Find parity of binary number stored in accumulator

Use an algorithm similar to one in Question 1 to find the parity (odd/even) of a binary number stored in the accumulator.

  Reason for problem encounter in deleting path variables

Discuss some of the problems he may soon encounter and explain the reasons for these problems. How could he easily return path to its original value?

  Value of variable immediately before that process terminates

Suppose all fork calls are successful. Inside node for each process, illustrate value of variable x immediately before that process terminates.

  Write one function that reads the input using alias paramete

Write one function that reads the input using alias parameters (reference parameters).Write a second function that calculates the pay amount. If the salesperson owes money, thereturn amount from the function is a negative number.

  Can a computer system function without one of these element

- What purposes do CPUs, memory and I-O devices individually serve in a computer system? - How do these 3 elements work together to compute? - Can a computer system function without one of these elements?

  Identify major points to include in communications plan

Identify the major points you would include in a communications plan at this point in the project? what advice would you give your project team to help it manage the user expectations?

  Does the diagram above represent a function f: x ? y

Does the diagram above represent a function f: X → Y? Explain why or why not

  Human and nature dynamics (handy) model

This paper is centered around some results obtained from the Human and Nature Dynamics (HANDY) model. This model is equation 3 in their paper.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd