Question

In: Computer Science

C# Only Create a class named Customer that implements IComparable interface. Create 3 Customer class fields:...

C# Only

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 1 russell 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

Solutions

Expert Solution

sing System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace question
{
class CreditCustomer
{
public static void Main(string[] args)
{
Customer CustomerOne = new Customer(100, "Sam", 10);
Customer CustomerTwo = new Customer(1200, "Martin", 5);
Customer CustomerThree = new Customer(1100, "Josh", 3);Console.WriteLine(CustomerOne.ToString());
Console.WriteLine(CustomerTwo.ToString());
Console.WriteLine(CustomerThree.ToString());CompareNumbers(CustomerOne,CustomerTwo);
CompareNumbers(CustomerOne, CustomerThree);
System.Console.ReadLine();
}
public static void CompareNumbers(Customer CustomerOne, Customer CustomerTwo)
{
if(CustomerOne.Equals(CustomerTwo))
Console.WriteLine("{0} for {1} has the same Customer" + "number as" + "{2} for{3}",
CustomerOne.CustomerNum, CustomerOne.CustomerName, CustomerTwo.CustomerNum, CustomerTwo.CustomerName);
}//Create a class named Customer
public class Customer
{
//create 3 customer class fields: Customer number, Customer Name and amoutn due.
//create automatic accessors for each field.public int customerNum;
public string customerName;
public double amountDue;
public int quantity;
public const double ItemPrice = 19.95;public Customer(int cusNum, string CusName, int numCus)
{
customerNum = cusNum;
customerName= CusName;
Quantity = numCus;
}public int CustomerNum
{
get
{
return CustomerNum;
}
set
{
CustomerNum = value;
}
}public string CustomerName
{
get
{
return customerName;
}
set
{
customerName = value;
}
}public int Quantity
{
get
{
return quantity;
}
set
{
quantity = value;
amountDue = quantity*ItemPrice;
}
}
public double AmountDue
{
get
{
return amountDue;
}
}
public override string ToString()
{
return(GetType()+""+ CustomerNum + "" + CustomerName + "" + Quantity+ "@" + ItemPrice.ToString("C2") + amountDue.ToString("C2"));
}public override bool Equals(object e)
{
bool equal;
Customer temp = (Customer)e;
if(CustomerNum == temp.CustomerNum)
equal = true;
else
equal = false;
return equal;
}
public override int GetHashCode()
{
return CustomerNum;
}
}
}
}

//Please mention if u got any doubts,thank you.....


Related Solutions

in c#: Create a class named Square that contains fields for area and the length of...
in c#: Create a class named Square that contains fields for area and the length of a side and whose constructor requires a parameter for the length of one side of a Square. The constructor assigns its parameter to the length of the Square’s side field and calls a private method that computes the area field. Also include read-only properties to get a Square’s side and area. Create a class named DemoSquares that instantiates an array of ten Square objects...
If a class A implements interface I1 and class C and D are derived from class...
If a class A implements interface I1 and class C and D are derived from class A, a variable of type I1 can be used to hold references of what type of objects? which one is correct 1. A, C, and D 2. A and D
JAVA code Create a new class called BetterDiGraph that implements the EditableDiGraph interface See the interface...
JAVA code Create a new class called BetterDiGraph that implements the EditableDiGraph interface See the interface below for details. EditableDigraph below: import java.util.NoSuchElementException; /** * Implements an editable graph with sparse vertex support. * * */ public interface EditableDiGraph {    /** * Adds an edge between two vertices, v and w. If vertices do not exist, * adds them first. * * @param v source vertex * @param w destination vertex */ void addEdge(int v, int w); /** *...
Create “New Class…” named Book to store the details of a book Declare 3 fields for...
Create “New Class…” named Book to store the details of a book Declare 3 fields for the details of the book: field named author of type String field named title of type String field named callNumber of type String Add overloaded constructors with the following headers and make sure each constructor has only 1 statement in the body that makes an internal method call to setBookDetails: public Book(String author, String title, String callNumber) public Book(String author, String title) HINT: Initialize...
Create a class named “Car” which has the following fields. The fields correspond to the columns...
Create a class named “Car” which has the following fields. The fields correspond to the columns in the text file except the last one. i. Vehicle_Name : String ii. Engine_Number : String iii. Vehicle_Price : double iv. Profit : double v. Total_Price : double (Total_Price = Vehicle_Price + Vehicle_Price* Profit/100) 2. Write a Java program to read the content of the text file. Each row has the attributes of one Car Object (except Total_Price). 3. After reading the instances of...
WRITE IN C++ Create a class named Coord in C++ Class has 3 private data items...
WRITE IN C++ Create a class named Coord in C++ Class has 3 private data items               int xCoord;               int yCoord;               int zCoord; write the setters and getters. They should be inline functions               void setXCoord(int)             void setYCoord(int)            void setZCoord(int)               int getXCoord()                     int getYCoord()                   int getZCoord() write a member function named void display() that displays the data items in the following format      blank line      xCoord is                          ????????      yCoord is                          ????????      zCoord...
How do you write the constructor for the three private fields? public class Student implements Named...
How do you write the constructor for the three private fields? public class Student implements Named { private Person asPerson; private String major; private String universityName; @Override public String name() { return asPerson.name(); }
write program in java Create a class named PersonalDetails with the fields name and address. The...
write program in java Create a class named PersonalDetails with the fields name and address. The class should have a parameterized constructor and get method for each field.  Create a class named Student with the fields ID, PersonalDetails object, major and GPA. The class should have a parameterized constructor and get method for each field. Create an application/class named StudentApp that declare Student object. Prompts (GUI input) the user for student details including ID, name, address, major and GPA....
~~~USING C# ONLY~~~ Create a console application Design a class named Person with properties for holding...
~~~USING C# ONLY~~~ Create a console application Design a class named Person with properties for holding a person’s name, address, and telephone number. Design a class named Customer, which is derived from the Person class. The Customer class should have the variables and properties for the customer number, customer email, a spentAmount of the customer’s purchases, and a Boolean variable indicating whether the customer wishes to be on a mailing list. It also includes a function named calcAmount that calculates...
(The Colorable interface) Design an interface named Colorable with a void method named howToColor(). Every class...
(The Colorable interface) Design an interface named Colorable with a void method named howToColor(). Every class of a colorable object must implement the Colorable interface. Design a class named Square that extends GeometricObject and implements Colorable. Design another class named Triangle that extends GeometricObject and implements Colorable. Implement howToColor in Square to display the message Color all four sides. Implement howToColor in Triangle to display the message Color all three sides. Draw a UML diagram that involves Colorable, Square, Triangle,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT