8 Replies - 560 Views - Last Post: 17 October 2013 - 11:44 AM Rate Topic: -----

#1 kaloputi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-October 13

got stuck in assignment

Posted 17 October 2013 - 09:06 AM

Develop a Visual Studio C# Console Application for the following specifications:

User has data for Invoices. Each Invoice has four data items: Part Number(int), Description(string), Quantity(int) and Price per Unit(decimal). Data is given below. Write the LINQ code to perform the following queries on an array of Invoices and show the output of each Query with appropriate Heading for each.

a) List of Invoices sorted (ascending) by Description

B) List of Invoices with Description and Quantity and sort (ascending) by Quantity

c) Calculate Item Total (Quantity * Price per Unit) for each invoice item and output a list of Invoices with Decriptions and Item Totals

d) Using the results from part© above, display a list of Description and Item Totals for Invoices with Item Totals between $200.00 and $800.00

-----------------------------

Invoice data

Part Number Decription Quantity Price per Unit

83 Electric Sander 7 57.95

24 Power Saw 18 99.99

7 Sledge Hammer 11 21.50

77 Hammer 76 11.99

39 Lawn Mower 3 129.90

68 Screw Driver 106 6.99

This is what i got




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dsproject4
{
    class Program
    {
        static void Main(string[] args)
        {
            // array of invoices
		Invoice[] invoices = {
			new Invoice("83", "Electric Sander", "7", 59.98),
			new Invoice("24", "Power Saw", "18", 99.99),
			new Invoice("7", "Sledge Hammer", "11", 21.5),
			new Invoice("77", "Hammer", "76", 11.99),
			new Invoice("39", "Lawn Mower", "3", 79.5),
			new Invoice("68", "Screwdriver", "106", 6.99),
			
		};

		

	
		dynamic Desc = from i in invoicesorderby i.PartDescription ascending;
		Display(Desc, "By Part Description Ascending");

		
		dynamic SortDescQuant = from invoice in invoicesi.PartDescriptioninvoice.Quantityorderby q ascending;
		Display2(SortDescQuant, "Part Description and Quantity, sort by Quantity");

		
		dynamic InvoiceTotal = from invoice in invoicesi.PartDescription(i.Quantity * i.Price).ToString("c2")orderby Convert.ToDecimal(t) ascending;
		Display2(InvoiceTotal, "Total");

		
		dynamic between = from l in InvoiceTotalwhere Convert.ToDecimal(l.t) >= 200 && Convert.ToDecimal(l.t) <= 800l;
		Display2(between, "Total Prices Between $200 & $800");

		

        }
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: got stuck in assignment

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4312
  • View blog
  • Posts: 7,468
  • Joined: 08-June 10

Re: got stuck in assignment

Posted 17 October 2013 - 09:21 AM

You still haven't asked a question. You've posted an assignment and the code you've tried.

Tell us what isn't working. Tell us what line causes problems. Tell us what output you get, and what you expect. That's the kind of thing we need to help you. It's not our job to decipher your assignment and figure out what's wrong. Please read the two links in my signature.

Side note: don't use dynamic unless you have a damn good reason. I don't actually see a good reason to be using them here. You might have it confused with var, which is completely different.

Lastly, you are making a call to a Display2 method, but I do not see that method defined in your code. Make sure you post all relevant code.
Was This Post Helpful? 0
  • +
  • -

#3 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 996
  • View blog
  • Posts: 2,393
  • Joined: 04-October 09

Re: got stuck in assignment

Posted 17 October 2013 - 09:22 AM

Don't use dynamic types. At the point you are in your learning you don't need them. I'd rather you use 'var', and I hate using 'var' :)

That said, what seems to be the issue? You having errors?
Was This Post Helpful? 0
  • +
  • -

#4 kaloputi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-October 13

Re: got stuck in assignment

Posted 17 October 2013 - 09:24 AM

it shows 28 errors, the type of namespace invoice vannot be found whats that meant
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4312
  • View blog
  • Posts: 7,468
  • Joined: 08-June 10

Re: got stuck in assignment

Posted 17 October 2013 - 09:28 AM

That's because you haven't defined it anywhere. I think you need to talk to your professor (if this is homework) or read the book/tutorial a bit more closely if this is work on your own time. We can't give you a short course on C# programming. I can suggest our Learning C# series as a place for beginners to start.
Was This Post Helpful? 0
  • +
  • -

#6 kaloputi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-October 13

Re: got stuck in assignment

Posted 17 October 2013 - 09:30 AM

shows 4 errors now, says query body must ends with select clause or a group clause
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4312
  • View blog
  • Posts: 7,468
  • Joined: 08-June 10

Re: got stuck in assignment

Posted 17 October 2013 - 09:35 AM

So end your query body with a select clause or a group clause. This is going nowhere fast. We're not your online debugger. Try searching google for your errors before asking; most errors are common and have simple answers and you'll get them a lot faster that way than waiting for one of us to explain it to you.
Was This Post Helpful? 0
  • +
  • -

#8 synlight  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 84
  • View blog
  • Posts: 557
  • Joined: 14-September 11

Re: got stuck in assignment

Posted 17 October 2013 - 09:45 AM

OMG. I'm dying @Curtis. Sorry OP, not trying to be rude.. online debugger, indeed *snort*
Was This Post Helpful? 0
  • +
  • -

#9 Michael26  Icon User is offline

  • Radar love
  • member icon

Reputation: 332
  • View blog
  • Posts: 1,420
  • Joined: 08-April 09

Re: got stuck in assignment

Posted 17 October 2013 - 11:44 AM

I think OP is in over his head, using LINQ queries, dynamic without proper understanding what they do is rushing ahead on bulls horns, i suggest you heed Curtis advice and start from beginning.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1