Assignment6yourlastnamecs Implement the following requiremen
[Assignment6_yourlastname.cs] Implement the following requirements:
Create a class named Customer that implements IComparable interface.
Create 3 Customer class fields: Customer number, customer name, and amount due. Create automatic accessors for each field.
Create an Customer class constructor that takes parameters for all of the class fields and assigns the passed values through the accessors.
Create a default, no-argument Customer class constructor that will take no parameters and will cause default values of (9, \"ZZZ\", 0) to be sent to the 3-argument constructor.
Create an (override) Equals() method that determines two Customers are equal if they have the same Customer number.
Create an (override) GetHashCode() method that returns the Customer number.
Create an (override) ToString() method that returns a string containing the general Customer information (eg: CreditCustomer 1russell AmountDue is $4,311.00 Interest rate is 0.01). Display the dollar amounts in currency format.
Implement CompareTo to compare object customer numbers for >, <, == to implement sorting for the array of objects.
Create a CreditCustomer class that derives from Customer and implements IComparable interface.
Create a class variable named Rate using an automatic accessor.
Create an CreditCustomer class constructor that takes parameters for the Customer class fields customer number, name, amount, and rate percent that sets the Rate CreditCustomer variable to the rate percentage. Pass the id number, name and amount back to the base Customer class constructor.
Create a default, no-argument CreditCustomer class constructor that will take no parameters and will cause default values of (0, \"\", 0, 0) to be sent to the 4-argument CreditCustomer constructor.
Create an (override) ToString() method that returns a string containing the general Customer information (eg: CreditCustomer 1 russell AmountDue is $4,311.00 Interest rate is 0.01 Monthly payment is $179.63). Display the dollar amounts in currency format.
Implement CompareTo to compare CreditCustomer objects based on customer numbers for >, <, == to implement sorting for the array of objects.
In Main:
Create an array of five CreditCustomer objects.
Prompt the user for values for each of the five Customer object; do NOT allow duplicate Customer numbers and force the user to reenter the Customer when a duplicate Customer number is entered.
CreditCustomer objects should be sorted by Customer number before they are displayed.
When the five valid Customers have been entered, display them all, display a total amount due for all Customers, display the same information again with the monthly payment for each customer. See the input/output example shown below.
Create a static GetPaymentAmounts method that will have the current Credit customer object as a parameter and returns a double value type. Each CreditCustomer monthly payment will be 1/24 of the balance (amount due). The computed monthly individual customer payment will be returned for each CreditCustomer object in the object array.
Internal Documentation.
Note that you will be overriding three object methods in the Customer class and one in the CreditCustomer class. Don\'t forget about IComparable.
An example of program output might look like this:
Enter customer number 3
 Enter name johnson
 Enter amount due 1244.50
 Enter interest rate .10
 Enter customer number 2
 Enter name jensen
 Enter amount due 543.21
 Enter interest rate .15
 Enter customer number 2
 Sorry, the customer number 2 is a duplicate.
 Please reenter 5
 Enter name swenson
 Enter amount due 6454.00
 Enter interest rate .11
 Enter customer number 1
 Enter name olson
 Enter amount due 435.44
 Enter interest rate .20
 Enter customer number 4
 Enter name olafson
 Enter amount due 583.88
 Enter interest rate .25
 
 Summary:
 
 CreditCustomer 1 olson AmountDue is $435.44 Interest rate is 0.2
 CreditCustomer 2 jensen AmountDue is $543.21 Interest rate is 0.15
 CreditCustomer 3 johnson AmountDue is $1,244.50 Interest rate is 0.1
 CreditCustomer 4 olafson AmountDue is $583.88 Interest rate is 0.25
 CreditCustomer 5 swenson AmountDue is $6,454.00 Interest rate is 0.11
 
 AmountDue for all Customers is $9,261.03
 
 Payment Information:
 
 CreditCustomer 1 olson AmountDue is $435.44 Interest rate is 0.2
 Monthly payment is $18.14
 CreditCustomer 2 jensen AmountDue is $543.21 Interest rate is 0.15
 Monthly payment is $22.63
 CreditCustomer 3 johnson AmountDue is $1,244.50 Interest rate is 0.1
 Monthly payment is $51.85
 CreditCustomer 4 olafson AmountDue is $583.88 Interest rate is 0.25
 Monthly payment is $24.33
 CreditCustomer 5 swenson AmountDue is $6,454.00 Interest rate is 0.11
 Monthly payment is $268.92
 Press any key to continue . . .
 Declaring a child class:
public class Fiction : Book //for extending classes, you must use a single colon between the derived class name and its base class name
 {
 private:
 //put your private data members here!
 public:
 //put your public methods here!
 }
NOTE: when you instantiate an object of Fiction child class, you will inherit all the data members and methods of the Book class
Solution
Here is the required C# code. Please run it and rate the answer if you find it good. Thanks.
=========================================
using System.IO;
 using System;
 using System.Collections;
 class Customer : IComparable
 {
 protected int CustomerNumber {get;set;}
 protected String CustomerName {get;set;}
 protected float AmountDue {get;set;}
 
 
 public Customer():this(9,\"ZZZ\",0)
 {
   
 }
 public Customer(int id,String name,float amt)
 {
 CustomerNumber=id;
 CustomerName=name;
 AmountDue=amt;
 }
 public override bool Equals(object obj)
 {
 if (obj == null)
 return false;
 if (this.GetType() != obj.GetType()) return false;
   
 Customer p = (Customer)obj;
 return (this.CustomerNumber == p.CustomerNumber);
 }
   
 public override int GetHashCode()
 {
 return CustomerNumber;
 }
   
   
 public int CompareTo(object obj) {
 if (obj == null) return 1;
Customer other = obj as Customer;
 if (other != null)
 return this.CustomerNumber-other.CustomerNumber;
 else
 throw new ArgumentException(\"Object is not a Customer\");
 }
   
 public String ToString()
 {
 return \"Customer:\"+CustomerNumber+\" \"+CustomerName+
 \"\\t AmountDue:$\"+AmountDue;
 }
 
 }
 class CreditCustomer : Customer
 {
 protected float Rate {get;set;}
 public CreditCustomer():this(0,\"\",0,0)
 {
   
 }
 public CreditCustomer(int id,String name,float amount,float rate):base(id,name,amount)
 {
 
 this.Rate=rate;
 }
 public String ToString()
 {
 return base.ToString()+\"\\t Interest Rate is \"+Rate+\"\\tMonthly Payment:$\"+(AmountDue/24);
 }
 }
 class Program
 {
 static void Main()
 {
 ArrayList customers=new ArrayList();
 int count=5; //prompting for 5 customers
 int i=0,id;
 String name;
 float amount,rate;
 CreditCustomer c;
 while(i<count)
 {
 Console.WriteLine(\"Enter details for Customer \"+(i+1));
 Console.WriteLine(\"Enter Id:\");
 id=Convert.ToInt32(Console.ReadLine());
 Console.WriteLine(\"Enter Name:\");
 name=Console.ReadLine();
 Console.WriteLine(\"Enter Amount:\");
 amount=Convert.ToSingle(Console.ReadLine());
 Console.WriteLine(\"Enter Rate:\");
 rate=Convert.ToSingle(Console.ReadLine());
   
 c=new CreditCustomer(id,name,amount,rate);
 if(customers.Contains(c)) //uses the compareto method from icomparable
 {
 Console.WriteLine(\"Duplicate Customer !! Enter details again\");
 continue;
 }
 else
 {
 customers.Add(c);
 i++;
 }
   
 }
   
    //uses the compareto method from icomparable for sorting
   
 customers.Sort();
   
 foreach (CreditCustomer cust in customers)
 Console.WriteLine(cust.ToString());
 }
 }
![[Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class [Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class](/WebImages/37/assignment6yourlastnamecs-implement-the-following-requiremen-1110905-1761589005-0.webp)
![[Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class [Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class](/WebImages/37/assignment6yourlastnamecs-implement-the-following-requiremen-1110905-1761589005-1.webp)
![[Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class [Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class](/WebImages/37/assignment6yourlastnamecs-implement-the-following-requiremen-1110905-1761589005-2.webp)
![[Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class [Assignment6_yourlastname.cs] Implement the following requirements: Create a class named Customer that implements IComparable interface. Create 3 Customer class](/WebImages/37/assignment6yourlastnamecs-implement-the-following-requiremen-1110905-1761589005-3.webp)
