
(Querying an Array of Invoice Objects) Use the class Invoice provided in the lab assignment to create an array of Invoice objects.
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).Write a console application that performs the following queries on the array of Invoice objects and displays 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.
Sample Data
83 Electric sander 7 57.98
24 Power saw 18 99.99
7 Sledge hammer 11 21.50
77 Hammer 76 11.99
39 Lawn mower 3 79.50
68 Screwdriver 106 6.99
56 Jig saw 21 11.00
3 Wrench 34 7.50
Class Invoice
public class Invoice
{
// declare variables for Invoice object
private int quantityValue;
private decimal priceValue;
// auto-implemented property PartNumber
public int PartNumber { get; set; }
// auto-implemented property PartDescription
public string PartDescription { get; set; }
// four-argument constructor
public Invoice( int part, string description,
int count, decimal pricePerItem )
{
PartNumber = part;
PartDescription = description;
Quantity = count;
Price = pricePerItem;
} // end constructor
// property for quantityValue; ensures value is positive
public int Quantity
{
get
{
return quantityValue;
} // end get
set
{
if ( value > 0 ) // determine whether quantity is positive
quantityValue = value; // valid quantity assigned
} // end set
} // end property Quantity
// property for pricePerItemValue; ensures value is positive
public decimal Price
{
get
{
return priceValue;
} // end get
set
{
if ( value >= 0M ) // determine whether price is non-negative
priceValue = value; // valid price assigned
} // end set
} // end property Price
// return string containing the fields in the Invoice in a nice format
public override string ToString()
{
// left justify each field, and give large enough spaces so
// all the columns line up
return string.Format( "{0,-5} {1,-20} {2,-5} {3,6:C}",
PartNumber, PartDescription, Quantity, Price );
} // end method ToString
} // end class Invoice

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- # dates and times with lubridateinstall.packages("nycflights13") library(tidyverse)library(lubridate)library(nycflights13) Qustion: Create a function called date_quarter that accepts any vector of dates as its input and then returns the corresponding quarter for each date Examples: “2019-01-01” should return “Q1” “2011-05-23” should return “Q2” “1978-09-30” should return “Q3” Etc. Use the flight's data set from the nycflights13 package to test your function by creating a new column called quarter using mutate()arrow_forwardHelp and show me fix an error problem? def decorator(decorated_function:callable): def wrapper_function(*args, **kwargs): #this is where we make modifications to the arguments before invoking the decorated function return_value = decorated_function(*args, **kwargs) #this is where we make modifications to the returned value after invoking the decorated function return return_value return wrapper_function def reverse_decorator(function:callable): This question is meant to test your knowledge of creating a decorator to decorate a function that accepts no arguments and alters the decorated function's output. This decorator will decorate a function that only returns strings and has no arguments. This decorator should reverse the string value returned by the decorated function and return the reversed string. In other words, if a function is decorated by this decorator all of the functional output should be the reverse of its normal output. def…arrow_forwardC+++ I need help filling in missing/needed code to to do the following: Read two doubles as the forceApplied and the contactArea of a BallObject object. Declare and assign pointer myBallObject with a new BallObject object using the forceApplied and the contactArea as arguments in that order. Then call myBallObject's IncreaseForceAppliedAndContactArea() member function. Ex: If the input is 3.0 2.5, then the output is: #include <iostream>#include <iomanip>using namespace std; class BallObject { public: BallObject(double forceAppliedValue, double contactAreaValue); void IncreaseForceAppliedAndContactArea(); void Print(); private: double forceApplied; double contactArea;};BallObject::BallObject(double forceAppliedValue, double contactAreaValue) { forceApplied = forceAppliedValue; contactArea = contactAreaValue;}void BallObject::IncreaseForceAppliedAndContactArea() { forceApplied = forceApplied * 5.0; contactArea = contactArea * 5.0;…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





