C# Answers

Questions answered by Experts: 1 362

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Create ProductMock Entity which throws DataEntryException when its properties initialize with following values. Get the Product details from the user and handle in-built and user defined exception. Refer the class diagram given below :


Condition | Exception Message

__________________________________________________________________________________

productID <=0 | Product ID must be greater than zero productName = = “” | Product Name cannot be left blank

price <=0 | Price of product must be greater than zero.

productName | Product Name should have alphabets and numbers only


Product Mock:

ProductId: int

ProductName: String

Price: Double


Output:

Enter Id: -32

Enter Product Name: Compaq Laptop

Enter Price: 32000


Product Id must be greater than 0


ABC Corp wants to maintain list of Customers. While accepting the data, you need to validate CreditLimit property. If the value is invalid, you need to raise Exception. We need to implement custom exception class to implement the same.


Task 1: Define a Customer class with following members CustomerId, Customer Name, Address, City, Phone, CreditLimit


Task 2: Define the properties for all these members.


Task 3: Define two constructors (Default and Parameterised) to assign the values.


Task 4: You need to validate the CreditLimit. If the value is above 50000, then you need to raise Exception to handle this. Create InvalidCreditLimit custom Exception class to achieve the same.


Task 5: Use the Exception class created to throw the exception. Ensure that the Client application catches the exception and handles the error properly.


There is a Change request from the customer. It is as follows: You need to calculate Interest paid by banks on Saving Account.


Task 1 : Add a function declaration “void CalculateInterest()” in the interface. Define the functions in the concrete classes such as ICICI accounts get 7% interest and HSBC gives 5% interest.


The purpose is to create Circle and Triangle class by inheriting the Shape Class. Both the inherited classes should override the WhoamI() method of the Shape Class. The code has some bugs. Identify the Bugs and fix them.


public class Shape

{

private void WhoamI()

{

Console.WriteLine("I m Shape");

}

}

class Triangle : public Shape

{

public virtual void WhoamI()

{

Console.WriteLine("I m Triangle");

}

}

public class Circle : public Shape

{

void WhoamI()

{

Console.WriteLine("I m Circle");

}

}

class Program

{

static void Main(string[] args)

{

Shape s; s = new Triangle();

s.WhoamI();

s = new Circle();

s.WhoamI();

Console.ReadKey();

}

}


Create Supplier instance in SupplierTest class, invoke AcceptDetails method to accept the details of the supplier from the user and invoke DisplayDetails method to display the given details of the supplier.


Supplier:

Supplierid: int

SupplierName:

City: String

PhoneNum: String

Email: String

____________________

+Accept Details(Supplier): Void

+Display Details: Supplier



String Supplier Test

_________________

+Main(String[] args)


Define a single dimension array of strings to hold the name of City. Accept some values from the user and store them in the array. Use foreach loop to print all the data of the array. 


 Create a Class named BooksDemo accepts and displays the details of books using multidimensional array.

BooksDemo

-colName:string[4] = {"BookTitle", "Author", "Publisher", "Price"}

-bookDetails: string[2,4]

+Main(args: string[])


2. Write a program to define a two dimensional array of numbers to store 5 rows and 6 columns. Write a code to accept the data, assign it in array, and print the data entered by the user.


Create a Class named BooksDemo accepts and displays the details of books using multidimensional array.


BOOKDemo:-

colName: String[4] = {"Book title", "Author", "Publisher", "Price"}

bookDetails: String[2, 4]

____________________

+Main(args: string[])


Write a program to define a two dimensional array of numbers to store 5 rows and 6 columns. Write a code to accept the data, assign it in array, and print the data entered by the user.


LATEST TUTORIALS
APPROVED BY CLIENTS