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;
Programming
[Solved] SOLVED: Assignment No.2: solution
$25
File Name: SOLVED:_Assignment_No.2:_solution.zip
File Size: 310.86 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.