Guest User

Untitled

a guest
Jun 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. namespace CashRegister
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. // declare a new CashRegister object
  8. CashRegister myRegister = new CashRegister ();
  9.  
  10. // add several dollar amounts
  11. myRegister.add (20.00);
  12. myRegister.add (15.50);
  13. myRegister.add (3.75);
  14.  
  15. // display the current cash balance
  16. Console.WriteLine("The register has: $" + myRegister.????());
  17. Console.ReadKey();
  18. }
  19. }
  20.    // CashRegister object definition
  21.    class CashRegister
  22.    {
  23.       // declare a property (class variable)
  24.       double cash = 0.0;
  25.  
  26. // define an add() method that takes one double "amount" parameter
  27. public void add(double amount)
  28.       {
  29.          Console.WriteLine("Adding $" + amount);
  30.          cash += amount;
  31.       }
  32.  
  33. // define a report() method that returns one double value
  34. public double report()
  35.        {
  36.           return cash;
  37.        }
  38.    }
  39. }
Add Comment
Please, Sign In to add comment