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

  Explain how they might be avoided

when is compaction of secondary storage beneficial from the file managers perspective? give several examples. list some problems that could be presented as a result of compaction and explain how they might be avoided.

  Create an instance variable credit limit to indicate

Create another sub class CreditCustomer. Create an instance variable credit limit to indicate the maximum limit ($500). Credit customers get a markup of 2% on the order price.

  Determine smallest value of x for which is safe state

System has 4 processes and 5 allocatable resources. The current allocation and maximum needs are as follows: Determine the smallest value of x for which this safe state.

  Executing intrusion detection system

Your company is trying to decide whether to execute intrusion detection system (IDS), or intrusion prevention system (IPS).

  Use active directory for authentication and authorization

Why would an organization choose to use Active Directory for authentication and authorization over other solutions such as Novell Netware or a free solution such as Linux based LDAP.

  Explaining rea modeling and rea diagrams

REA data modeling does not include traditional accounting elements such as ledgers, chart of accounts, debits and credits.

  What is average seek time

Tracks traversed Disk receives a request to access a random sector on a random track. Assume the head starts at track 0. What is the average seek time?

  Write a java program that creates an array of integers

It should also keep track of a value that appears most often, display what that value was, and how often that value appeared in the array. You may simplify by filling myArray with values such that only one value appears most often.

  What decimal number would the ieee 754

What decimal number would the IEEE 754 single precision floating point number 0xCAE80000 (this is in hex) be? Write your final answer in scientific notation as m x 10 p where p is an integer.

  Explain daytime processing load

Assume daytime processing load consists of 60% CPU activityand 40% disk activity. Your customers are complaining that the system is slow. Which would you select to yield best performance improvement for least amount of money?

  What are the differences between file viruses

1. What are the differences between file viruses, boot viruses, macro viruses, and network viruses?

  How to choose optimal location of pipeline for oil field

A Consultant is to lay oil pipeline running east to west through the oil field of n wells. From each well spur pipeline is to be connected directly to main pipeline along shortest path.

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