Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEEDED IN C# please!! Use the class below to create an array of Invoice objects. Use the sample data shown in Fig. 9.8. Class Invoice

NEEDED IN C# please!!

Use the class below to create an array of Invoice objects. Use the sample data shown in Fig. 9.8. Class Invoice includes four properties, a PartNumber (type int), a PartDescription (type string), a Quantity of the item being purchased (type int) and a Price (type decimal). Perform the following queries on the array of Invoice objects and display the results: a) Use LINQ to sort the Invoice objects by PartDescription. b) Use LINQ to sort the Invoice objects by Price. c) Use LINQ to select the PartDescription and Quantity and sort the results by Quantity. d) Use LINQ to select from each Invoice the PartDescription and the value of the Invoice (i.e., Quantity * Price). Name the calculated column InvoiceTotal. Order the results by Invoice value. [Hint: Use let to store the result of Quantity * Price in a new range variable total]. e) Using the results of the LINQ query in part d, select the InvoiceTotals in the range $200 to $500.

image text in transcribed

Class Invoice:

// Invoice.cs

// Invoice for a hardware company

using System;

public class Invoice

{

string partNum;

string partDescription;

int quantity;

decimal unitPrice;

public Invoice(string pNum, string pDesciption, int q, decimal uPrice)

{

PartNum = pNum;

PartDescription = pDesciption;

Quantity = q;

UnitPrice = uPrice;

}

public string PartNum

{

get

{

return partNum;

} // end get

set

{

partNum = value;

} // end set

} // end

public string PartDescription

{

get

{

return partDescription;

} // end get

set

{

partDescription = value;

} // end set

} // end

public int Quantity

{

get

{

return quantity;

} // end get

set

{

if (value >= 0)

quantity = value;

} // end set

} // end

public decimal UnitPrice

{

get

{

return unitPrice;

} // end get

set

{

if (value >= 0M)

unitPrice = value;

} // end set

} // end

public decimal GetInvoiceAmount()

{

decimal amt = Quantity * UnitPrice;

return amt;

}

public override string ToString()

{

return string.Format("{0,-10}{1,-20}{2,-10}{3,10:C}", PartNum,

PartDescription, Quantity, UnitPrice);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

5. Arranging for the training facility and room.

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago