473,385 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

desperately need help

This is definitely not the smart thing to do as far as my learning goes,
but desperate situations call for desperate measures.

The final lab for my introduction to C programming class is due tomorrow.
I was on vacation when we went over how to read files, so basically my
only resources are the book, the course notes, and the examples.
Unfortunately for me, none of them are usefull at all, so pretty much i
don't have a clue as to what i should do.

I haven't read one topic on these forums, so i have no idea how the
community works around here. If you want to flame me for being an idiot,
i back you up 100%. But if you want to help me out, then you've basically
saved my grade and hopefully that makes you feel good, because it'll make
me feel 100x better.

Here's what i have to do:

Use an input file which has several lines of department number, item
number, quantity and cost per item. Assume that the input file has been
sorted by department number and that all the input values are valid.
Write a program to read the input file one line at a time, and print to an
output file a Summary Report which shows the department number, item
number, quantity, cost/item, value (quantity*cost), total for each
department, the number of items (assume a unique item number on each line)
and grand total (total of all values). The Summary Report (output file)
should look something like:
Department Item Quantity Cost/Item Value Totals
15 1389 4 3.20 12.80
15 3821 2 7.00 14.00
26.80
16 0122 8 2.50 20.00
20.00
19 1244 100 0.03 3.00
19 1245 20 4.00 80.00
19 2469 4 16.00 64.00
147.00
Number of Items: 6 Grand Total 193.80

Main should only open the files, and if they both open, call a function
(that you write) to print the summary report to the output file, then
close the files in main. (If either file doesn't open, print an error
message and quit the program.)
The summary report function must print headers to the output file. Also
in this report function, call the function that reads a line from the
input file (see below), do all the calculations (you could do them in
another function), print to the output file (one line at a time), count #
of lines (items) and accumulate the totals (all in a for loop). After the
end of the input file (and last item line printed), print the last
department total, the # of items, and the grand total with labels. Hint:
You'll need a counter and 2 totals (one for the departments, another for
the grand total), and a variable to store the previously read department
number (in order to know when a new department number was read).
DO NOT USE ANY EXTERNAL VARIABLES!!!
Include in your programs:
• A function to print the summary report (described above)
• A function to read a line of input that returns 0 if end of file
detected (call this from the summary report function)
• A for loop (count the # of lines using expr1 & expr3)
• Two text files (one for input, the other for output)
Nov 14 '05 #1
17 1939
Oops, i forgot; here's the input:
100 2398 45 67.89
108 3278 88 70.75
108 3421 123 8.99
108 4032 17 30.82
108 4360 56 18.78
121 5084 27 121.21
133 6599 5 204.08
133 6787 33 82.01
133 7121 12 73.35

Nov 14 '05 #2
EkteGjetost wrote:
This is definitely not the smart thing to do as far as my learning goes,
but desperate situations call for desperate measures.

The final lab for my introduction to C programming class is due tomorrow.
I was on vacation when we went over how to read files, so basically my
only resources are the book, the course notes, and the examples.
That should be sufficient.
Unfortunately for me, none of them are usefull at all, so pretty much i
don't have a clue as to what i should do.

I haven't read one topic on these forums, so i have no idea how the
community works around here. If you want to flame me for being an idiot,
i back you up 100%. But if you want to help me out, then you've basically
saved my grade and hopefully that makes you feel good, because it'll make
me feel 100x better.

Here's what i have to do:

Use an input file which has several lines of department number, item
number, quantity and cost per item. Assume that the input file has been
sorted by department number and that all the input values are valid.
Write a program to read the input file one line at a time, and print to an
output file a Summary Report which shows the department number, item
number, quantity, cost/item, value (quantity*cost), total for each
department, the number of items (assume a unique item number on each line)
and grand total (total of all values). The Summary Report (output file)
should look something like:
Department Item Quantity Cost/Item Value Totals
15 1389 4 3.20 12.80
15 3821 2 7.00 14.00
26.80
16 0122 8 2.50 20.00
20.00
19 1244 100 0.03 3.00
19 1245 20 4.00 80.00
19 2469 4 16.00 64.00
147.00
Number of Items: 6 Grand Total 193.80

Main should only open the files, and if they both open, call a function
(that you write) to print the summary report to the output file, then
close the files in main. (If either file doesn't open, print an error
message and quit the program.)
The summary report function must print headers to the output file. Also
in this report function, call the function that reads a line from the
input file (see below), do all the calculations (you could do them in
another function), print to the output file (one line at a time), count #
of lines (items) and accumulate the totals (all in a for loop). After the
end of the input file (and last item line printed), print the last
department total, the # of items, and the grand total with labels. Hint:
You'll need a counter and 2 totals (one for the departments, another for
the grand total), and a variable to store the previously read department
number (in order to know when a new department number was read).
DO NOT USE ANY EXTERNAL VARIABLES!!!
Include in your programs:
• A function to print the summary report (described above)
• A function to read a line of input that returns 0 if end of file
detected (call this from the summary report function)
• A for loop (count the # of lines using expr1 & expr3)
• Two text files (one for input, the other for output)


We won't do your homework for you but,
if you will attempt to write some code and post it here,
I'm sure that everyone would be glad to help.

Nov 14 '05 #3
Could you help get me started? Maybe a structure chart or something?

Thanks for the reply.

Nov 14 '05 #4
Mac
On Sun, 05 Dec 2004 21:52:17 -0500, EkteGjetost wrote:
This is definitely not the smart thing to do as far as my learning goes,
but desperate situations call for desperate measures.

The final lab for my introduction to C programming class is due tomorrow.
I was on vacation when we went over how to read files, so basically my
only resources are the book, the course notes, and the examples.
Unfortunately for me, none of them are usefull at all, so pretty much i
don't have a clue as to what i should do.

I haven't read one topic on these forums, so i have no idea how the
community works around here. If you want to flame me for being an idiot,
i back you up 100%. But if you want to help me out, then you've basically
saved my grade and hopefully that makes you feel good, because it'll make
me feel 100x better.

[snip]

You picked the worst possible place to ask people to do your homework for
you.

If this was plan A, I suggest you go to plan B immediately and not waste
any more time here. If this was plan B, go to plan C, and so on.

To me, I think it is basically impossible for you to finish the
assignment, so I recommend you give up and work on something else. Perhaps
you can still salvage a better grade in another class.

I am not trying to be negative, just realistic.

--Mac

Nov 14 '05 #5
EkteGjetost wrote:
Could you help get me started? Maybe a structure chart or something?


int main(int argc, char* argv[]) {
// your code goes here
return 0;
}

Nov 14 '05 #6
whoa whoa, how does this make me a troll? I'm sorry if i didn't understand
that i shouldn't be asking questions like that on these forums, but it's
not like i'm posting here just to be obnoxious. I'll do as much as i can
figure out, and hopefully someone will be able to either help me, or at
least give me a little guidance from there if that's ok.

Nov 14 '05 #7
Mac
On Mon, 06 Dec 2004 01:27:24 -0500, EkteGjetost wrote:
whoa whoa, how does this make me a troll? I'm sorry if i didn't understand
that i shouldn't be asking questions like that on these forums, but it's
not like i'm posting here just to be obnoxious. I'll do as much as i can
figure out, and hopefully someone will be able to either help me, or at
least give me a little guidance from there if that's ok.


E. Robert Tisdale implied that your Original Post was a troll. I did not.

If you post code to this group, and a clear description of what it is
supposed to do, people will USUALLY try to help you out a bit.

But you don't have time for many iterations of this sort of thing. That is
why I believe you will not finish in time.

Anyway, I bear you no malice or ill-will whatsoever. I have been in your
shoes before, many years ago, so I recognize your position.

Good luck.

--Mac

Nov 14 '05 #8
In article <5985d2bcb013629c3380239268dfc348
@localhost.talkaboutprogramming.com>, ch*********@gmail.com says...
whoa whoa, how does this make me a troll?
Mac didn't call you a troll, our resident troll, ERT did.
I'm sorry if i didn't understand that i shouldn't be asking
questions like that on these forums, but it's not like i'm
posting here just to be obnoxious. I'll do as much as i can
figure out, and hopefully someone will be able to either help
me, or at least give me a little guidance from there if that's
ok.
Nobody will write your homework assignment for you. On the other
hand, if you send me your professor's email address, I'll be
happy to submit something for you.

The point is, you said in the original artice that: my only resources are the book, the course notes, and the examples.


Those three things (especially the example code, perhaps the book,
considering on which is being used) should be more than sufficient
for anyone with a chance of passing a computer programming course
in the first place.

Waiting until the day before it's due to start, while taking vacation
during the middle of the class is not the best indicator that you
are cut out for this sort of thing.

If you had started a bit earlier, odds are you could have come up
with something, even if not working perfectly, people often help
correct code that is flawed here. They will not just write it for
you though, you have to put in effort up front.

--
Randy Howard (2reply remove FOOBAR)
"For some reason most people seem to be born without the part
of the brain that understands pointers." -- Joel Spolsky
Nov 14 '05 #9
"EkteGjetost" writes:
I'm sorry if i didn't understand
that i shouldn't be asking questions like that on these forums, but it's
not like i'm posting here just to be obnoxious. I'll do as much as i can
figure out, and hopefully someone will be able to either help me, or at
least give me a little guidance from there if that's ok.


There just isn't enough time. Programming contains such a seemingly
infinite number of little and not so little hurdles that IMO no beginner
could finish this by the end of the day. I saw the post last night and that
was my opinion then and it's even more so now. Think of taking 10 to 100
times what a skilled programmer would need in terms of time. It's not like
building a house or something where a pro could do it in x and an amateur
could do it in 2 x. There is a factor of five *or more* even between two
competent programmers, an astonishing difference in itself.

You need to negotiate at the very least a three day extension, perhaps more.
And presumably you have other courses to attend to. As someone has already
suggested, resign yourself to taking a fail on this and focus your energies
someplace else. I'm not averse to helping, it's just that you need too much
help.
Nov 14 '05 #10
Mac <fo*@bar.net> writes:
On Mon, 06 Dec 2004 01:27:24 -0500, EkteGjetost wrote:
whoa whoa, how does this make me a troll? I'm sorry if i didn't understand
that i shouldn't be asking questions like that on these forums, but it's
not like i'm posting here just to be obnoxious. I'll do as much as i can
figure out, and hopefully someone will be able to either help me, or at
least give me a little guidance from there if that's ok.


E. Robert Tisdale implied that your Original Post was a troll. I did not.


No, nobody called him a troll; the OP was the one who introduced the
word in to the discussion.

The OP's statement in the initial post:

I haven't read one topic on these forums, so i have no idea how
the community works around here. If you want to flame me for being
an idiot, i back you up 100%.

was refreshingly honest, but following that up with a complaint about
being called a troll (when nobody actually did so) seems less than
entirely consistent.

As for the OP's question, I'm in no more of a position to help than
anyone else.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #11
Square cat EkteGjetost was jivin' on Sun, 05 Dec 2004 21:52:17 -0500
in comp.lang.c.
desperately need help's a bad trip! Dig it!
This is definitely not the smart thing to do as far as my learning goes,
but desperate situations call for desperate measures.

The final lab for my introduction to C programming class is due tomorrow.
Left it a bit late, then, didn't we?
I was on vacation when we went over how to read files, so basically my
Let me get this straight. Instead of attending your classes, you
went away on vacation? And now you expect us to make up for your lack
of dedication to your studies?
only resources are the book, the course notes, and the examples.
Here's a thought. Why don't you try reading them?
Unfortunately for me, none of them are usefull at all, so pretty much i
No, well things like that are generally not very useful unless you
open them up and point your eyes at them.
don't have a clue as to what i should do.

I haven't read one topic on these forums, so i have no idea how the
community works around here.
Oh dear!
If you want to flame me for being an idiot,
i back you up 100%.
Oh good, you know what I'm thinking of you right now. That'll save
me the trouble of telling you.
But if you want to help me out, then you've basically
Sure. Which way did you come in?
saved my grade and hopefully that makes you feel good, because it'll make
me feel 100x better.
Interesting... uh... "logic"! Unfortunately it is flawed.
Here's what i have to do:


[Snip.]

So, you want us to do the work for you, to make up for your slacking
off?
Now, let me lay a few rules of newsgroup etiquette on you. First,
before you post to a newsgroup it is a must to lurk for a time (a
month or two is customary) to get a feel for the group and its rules
and to know whether your question has already been answered. It is
also a must to read a newsgroup's FAQ, welcome message, charter and
any other relevant material before posting to that newsgroup. (The
welcome message or charter will sually tell you what to read.)
comp.lang.c does not have a charter, however it does have a FAQ and a
welcome message.
Also, I notice elsewhere in this thread you follow up to messages
without quoting the text to which you are responding. Newsgroup
articles don't always arive in the order in which they were posted,
and sometimes they get lost. Unless you quote, with proper
attributions, what you are responding to, as I have done above, noone
will have any idea what you're talking about.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Nov 14 '05 #12
Keith Thompson wrote:
Mac <fo*@bar.net> writes: No, nobody called him a troll; the OP was the one who introduced the
word in to the discussion.
Sorry, but you are mistaken. ERTrollsdale in
<cp**********@nntp1.jpl.nasa.gov> changed the orginial header Subject: desperately need help to Subject: Troll Alert: desperately need help

Nov 14 '05 #13
Martin Ambuhl wrote:
Keith Thompson wrote:
Mac <fo*@bar.net> writes:

No, nobody called him a troll; the OP was the one who introduced
the word in to the discussion.


Sorry, but you are mistaken. ERTrollsdale in
<cp**********@nntp1.jpl.nasa.gov> changed the orginial header
> Subject: desperately need help

to
> Subject: Troll Alert: desperately need help


Which is just one more of Trollsdales sneaky changes. Most people
have the common decency to flag their subject changes with a (was:
....) indicator. Trollsdale is famous for at least altering quotes,
misinformation, and trolling.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #14

On Wed, 8 Dec 2004, CBFalconer wrote:

Martin Ambuhl wrote:
Keith Thompson wrote:
No, nobody called him a troll; the OP was the one who introduced
the word in to the discussion.


Sorry, but you are mistaken. ERTrollsdale in
<cp**********@nntp1.jpl.nasa.gov> changed the orginial header
> Subject: desperately need help

to
> Subject: Troll Alert: desperately need help


Which is just one more of Trollsdales sneaky changes. Most people
have the common decency to flag their subject changes with a (was:
...) indicator. Trollsdale is famous for at least altering quotes,
misinformation, and trolling.


I don't think you can fault Trollsdale for the subject line change.
It's not like he altered the OP's subject line; he just added a tag
on the front of it, the same way many contributors flag subjects with
"[OT]", or the way some sci.math readers try to flag JSH's posts with
"[JSH]" (it's a losing battle). I see nothing wrong with the subject-
line change, stylistically speaking.
Of course, the flagging of the OP as a "troll" is questionable, and
ERT does have a history of other misdemeanors (and a few felonies).
But I don't think ERT's "Troll Alert:" banner really counts as a
"sneaky change." It's just silly, incorrect, and a little rude, that's
all.

-Arthur,
way OT
Nov 14 '05 #15
Martin Ambuhl <ma*****@earthlink.net> writes:
Keith Thompson wrote:
Mac <fo*@bar.net> writes:

No, nobody called him a troll; the OP was the one who introduced the
word in to the discussion.


Sorry, but you are mistaken. ERTrollsdale in
<cp**********@nntp1.jpl.nasa.gov> changed the orginial header
> Subject: desperately need help

to
> Subject: Troll Alert: desperately need help


My mistake, I missed that.

Apparently irony is dead, but I never saw the obituary.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #16
CBFalconer <cb********@yahoo.com> scribbled the following:
Martin Ambuhl wrote:
Keith Thompson wrote:
Mac <fo*@bar.net> writes:
No, nobody called him a troll; the OP was the one who introduced
the word in to the discussion.
Sorry, but you are mistaken. ERTrollsdale in
<cp**********@nntp1.jpl.nasa.gov> changed the orginial header
> Subject: desperately need help

to
> Subject: Troll Alert: desperately need help

Which is just one more of Trollsdales sneaky changes. Most people
have the common decency to flag their subject changes with a (was:
...) indicator. Trollsdale is famous for at least altering quotes,
misinformation, and trolling.


Having your post called an "obvious troll" by ERT is actually a sign of
a well-written post and good understanding of C and/or Usenet behaviour.
Somehow ERT picks out the most clueful posts and calls them "obvious
trolls". I think he does this on purpose.
Being called an "obvious troll" by anyone other than ERT is a bad sign.
If that happens you should reconsider your arguments or stay quiet for
a while.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"O pointy birds, O pointy-pointy. Anoint my head, anointy-nointy."
- Dr. Michael Hfuhruhurr
Nov 14 '05 #17
On Wed, 8 Dec 2004 00:40:49 -0500 (EST), in comp.lang.c , "Arthur J.
O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote:
Of course, the flagging of the OP as a "troll" is questionable, and
ERT does have a history of other misdemeanors (and a few felonies).


Hmm, I always assumed that Trollsdale was notifying everyone that /he/ was
a troll when he did that.... :-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fabian | last post by:
Hi all there, I have already tried asking for help a couple of days ago. I try to rephrase better my problem: I need to grab a webpage that looks like this: <td width=80 align=center...
1
by: rdshultz | last post by:
I'm a complete newbie. Need to insert a Company logo into a database column to use later on in a check printing application. Read how to insert the pointer instead of the object into the column. ...
5
by: Rudy | last post by:
I am desperately seeking some help with a program that was supposed to have been completed last night. I have only been working with PHP for a week. I have tried and tried and tried, but I am...
0
by: chrisben | last post by:
Hi, Developing Env: .NET Studio in C#, windows 2000 target: a COM object used for excel user (RTD) I have no problem to compile and run the project in my machine. The excel is working great...
2
by: Johnny | last post by:
I am desperately trying to end the application but nothing seems to work in following code, language = Langu.... is always executed. The app starts with an Application.Run(new FrmMain()); Help! ...
2
by: Joe Rigley | last post by:
Help Please! I've been tasked with converting a portion of the corporate web site that currently utilizes local user accounts and NTFS via Basic Authentication to access certain files on the...
10
by: Susan Baker | last post by:
Hi Guys (and girls), I am in a bit of a bind. I'm looking for a simple "proof of concept" C# app (WinForm OR console) that sends a web request to a simple PHP script and receives BINARY data...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
7
by: jim | last post by:
I need to have 2 simple barcode reader applications finished by midnight tonight. I have never written any barcode reader software and need any help that you may be able to offer. I do not know...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.