Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# Programming (NO HARCODE PLEASE) Create a Money class that has as data members

ID: 3749394 • Letter: C

Question

C# Programming (NO HARCODE PLEASE)

Create a Money class that has as data members dollars and cents. Include IncrementMoney and DecrementMoney instance methods. Include constructors that enable the Money class to be instantiated with a single value representing the full dollar/cent amount as well as a constructor that enables you to create an instance of the class by sending two separate integer values representing the dollar and cent amounts. Include an instance method that returns as a string the num- ber of dollars, quarters, nickels, dimes, and pennies represented by the object’s value. Override the ToString( ) method to return the monetary amount formatted with currency symbols. Create a second class called MoneyApp to test your Money class.

Output:

Original Amount – 5 Dollars 36 Cents

Enter decrement amount – Enter the full dollar amount and cent amount: 2.36

Decrement Test

Original Amount: $5.36

Amount to subtract: 2.36

              New Dollar Amount: 3.00

              New Cent Amount: .0

              New Full Amount: $3.00

Press any key to see the next test……

Second Test:

Next Money Value: $4.02

Enter Increment amount (with decimal for cents).

Enter the full dollar and cent amount: 0.98

Second Test:

Original Amount – 4 dollars 2 cents

              Increment Test”

Amount to Add: 0.98

              New Amount: $5.00

Press any key to see the next test……

Third Test – input dollars and cents as separate values:

Enter Dollars: 7

Enter Cents as a whole number: 35

Full Dollar Amount:

Amount: $7.35

Press any key to see the next test……

Enter the full dollar and cent amount: 11.65

Dollars: 11

Quarters: 2

Dimes: 1

Nickels: 1

Pennies: 0

Press any key to see the next test……

Last Test – Enter the monetary amount as a single value (with a decimal):

Enter the full dollar and cent amount: 9.3

Dollars: 9.00

Cents: .30

Amount: $9.30

Explanation / Answer

This below code will help you to solve the given problem statement in C#. As of my knowledge i have present the below code. please let me know if it useful ..


public class Money
{
   int dollars;
   int cents;
  
   public void incrementMoney()
   {
   }
  
   public void decrementMoney()
   {
   }
  
   Money(int dollars)
   {
       dollars = dollars;
       cents = dollars;
   }
   Money(int dollars, int cents)
   {
       dollars = dollars;
       cents = cents;
   }
  
   public string toString()
   {
  
   int quarter = cents / 25;   
int dime = cents / 10;
   int nickel = cents / 5;
   int penny = cents;
   return dollars + quarters + nickels + dimes;
   }
  
}