Page 1
Page 1
Started By
Message

Yet another C# problem

Posted on 3/3/15 at 2:10 pm
Posted by Hu_Flung_Pu
Central, LA
Member since Jan 2013
22160 posts
Posted on 3/3/15 at 2:10 pm
Sorry. Need help again with yet another C# problem. Please help. I've done all I could and just can't get it right.




I can't seem to get loop to work correctly. I also can't figure out how to store the quantities and display them at the end.

Here is the problem.
3. Console app: A store only sells 4 items: Milk (barcode “732”; $4.50 per gallon; 0% sales tax), laundry detergent (barcode “120”; $8 per container; 9.5% sales tax), newspapers (barcode “222”; $1.50 each; 4% state tax) and boxes of cigarettes (barcode “000”; $10 each; 120% sales tax). Develop a program for a point of sale (POS) machine that does the following:
a. Waits for cashier to type in “checkout” or “logout”; if the latter, exit the application; else for checkout go thru following steps:
b. “scans” each item – on one line, enter barcode, a space, and then quantity. For each item:
i. Check if barcode recognized and qty numeric and > 1. If either not met, print an error msg and go back to (b).
ii. Calculate subtotal and tax (applying correct tax for the item), and add to order total.
iii. Add item line to receipt string.
c. Repeat (b) until a blank line is entered, then calculate and print a receipt similar to the following in format (note column alignments):
Milk $ 5.00 x 4 $ 20.00
Laundry Det $ 8.00 x 1 $ 8.00
---------------------------------------------------
Subtotal $ 28.00
Tax $ 2.66
---------------------------------------------------
Total $ 30.66

d. Return to step (a)

Posted by tom
Baton Rouge
Member since Jun 2007
8155 posts
Posted on 3/3/15 at 2:19 pm to
It's hilarious how they still make people write console applications just to make sure they gain no useful skills in the class.
Posted by Korkstand
Member since Nov 2003
28703 posts
Posted on 3/3/15 at 2:27 pm to
quote:

(note column alignments)
Posted by Korkstand
Member since Nov 2003
28703 posts
Posted on 3/3/15 at 2:58 pm to
quote:

It's hilarious how they still make people write console applications just to make sure they gain no useful skills in the class.
I think you're drawing a distinction where there isn't much of one. Classes teach the basics of programming (make something that works) first without burdening students with too much at once. Why bother with GUI shite if you don't even know how to write a loop?

Also, I think you discount the usefulness of console apps. Not only are they still extremely useful and more powerful than any GUI app in the Linux world, but there's not a huge difference between an app that gets parameters from the console and one that get parameters over the network. It wouldn't take much to convert OP's app into a server that could handle requests from any front end, whether it's a web app, or a desktop GUI, or a mobile app.
Posted by gmrkr5
NC
Member since Jul 2009
14887 posts
Posted on 3/3/15 at 2:59 pm to
quote:

C#


i found your problem
Posted by MamouTiger65
Baton Rouge, La
Member since Oct 2007
794 posts
Posted on 3/3/15 at 3:04 pm to
Write out the logic before you start coding. You only check once if they want to logout or checkout. That needs to be part of a loop. You will also need an array to store your receipt values so you can print out at the end.
Posted by tom
Baton Rouge
Member since Jun 2007
8155 posts
Posted on 3/3/15 at 3:08 pm to
While most of that is true, I'll bet the average student in the class spends more time formatting all that console nonsense like the problem requires than they do in the actual code.
Posted by Korkstand
Member since Nov 2003
28703 posts
Posted on 3/3/15 at 3:21 pm to
I know what you're saying, but formatting text is just a problem to be solved like any other.

I'm not trying to pick a fight, I just didn't want OP thinking he was learning useless shite.
Posted by MamouTiger65
Baton Rouge, La
Member since Oct 2007
794 posts
Posted on 3/3/15 at 3:23 pm to
quote:

While most of that is true, I'll bet the average student in the class spends more time formatting all that console nonsense like the problem requires than they do in the actual code.


Seems like creating a decent presentation layer would be far more tedious and less relevant to someone learning basic logic and data structures.
Posted by aaronb023
TeamBunt CEO
Member since Feb 2005
11774 posts
Posted on 3/3/15 at 3:38 pm to
You using sublime text?
Posted by Korkstand
Member since Nov 2003
28703 posts
Posted on 3/3/15 at 3:45 pm to
quote:

You using sublime text?
Probably VS
Posted by Hu_Flung_Pu
Central, LA
Member since Jan 2013
22160 posts
Posted on 3/3/15 at 5:18 pm to
I figured it out when I submitted it
Posted by Casty McBoozer
your mom's fat arse
Member since Sep 2005
35495 posts
Posted on 3/3/15 at 7:34 pm to
quote:

While most of that is true, I'll bet the average student in the class spends more time formatting all that console nonsense like the problem requires than they do in the actual code.


It's thinking like this that leads to a bunch of sloppy arse programmers writing sloppy arse code.
Posted by Hu_Flung_Pu
Central, LA
Member since Jan 2013
22160 posts
Posted on 3/3/15 at 8:51 pm to
oh goodness. fight! I'm going for Korkstand since he is one of my bosses on castle clash. just saying.
Posted by Hu_Flung_Pu
Central, LA
Member since Jan 2013
22160 posts
Posted on 3/3/15 at 8:53 pm to
quote:

You using sublime text?

VS 2013
Posted by UltimaParadox
Huntsville
Member since Nov 2008
40832 posts
Posted on 3/3/15 at 9:41 pm to
Still need help?
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on Twitter, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookTwitterInstagram