[SOLVED]  SOLVED: Assignment No.2: solution

25.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

4.7/5 - (7 votes)

Create a complex numbers class. Provide two consructors in it. Provide Tostring() method(override from object class).overload all necessary operators such as *,/,+,-,==,<,,!= Write unit tests for it. B. Create a currency class. Provide two constructors and override of ToString() method. Overload all necessary operators Class Currency { int dollars; int cents; public static currencyOperator+(currency lhs,currency rhs) { currency res=new currency(); res.cents=lhs.cents + rhs.cents; if(res.cents=100) { res.cents=res.cents -100; res.dollars=lhs.dollars+rhs.dollars +1; } else res.dollars=lhs.dollars+rhs.dollars; return res; } For – operator first convert to cents int totllhscents=lhs.dollars*100+lhs.cents; int totalrhscents=rhs.doallrs*100+rhs.cents; int rescents=lhstotalcents-rhstotalcents; res.dollars=rescents/100; res.cents=rescents%100;

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.