Thread: Homework Help

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    24

    Homework Help

    I am lost... I need to create a program that read a file called bagel.seq that contains information about a chain of bagel stores like sales of diffrent types of bagel. Then I have to create a report named bagel. rpt that is suppose to look like a formated table like the one below I just am unsure of how to make the table. and calculate the precentages. If someone could get me started out I would appreciate it, or show me a tutorial to look at. I am behind on my assignments due to the flu and the next assignment is a C++ that has to do with a triangle and a circle and calculations that I have no Idea how to do. So any help would be appreciated Everything is suppose to be more spaced out and formatted and the bagel.seq file contains all the information below I need to read the bagel.seq file into the table and then do the percentage calculations.
    Bogus Bagels Sales


    Store Bagel Bagel Number Bagel Store
    No. Description Price Sold Sales Percentage
    ----- ------------ ------ ------- ------- ----------

    1 Cinnamon $ 1.00 300 $ 300.00

    1 Plain $ 1.25 200 $ 250.00

    1 Garlic $ 1.20 100 $ 120.00

    2 Plain $ 1.10 100 $ 110.00

    2 Apple $ 1.30 50 $ 65.00

    2 Cheddar $ 1.50 75 $ 112.50

    3 Pumpkin $ 1.35 150 $ 202.50

    3 Apple $ 0.75 100 $ 75.00

    3 Cinnamon $ 1.35 150 $ 202.50

    3 Plain $ 1.00 100 $ 100.00

    Store 1 Totals $ 670.00 43.58%
    Store 2 Totals $ 287.50 18.70%
    Store 3 Totals $ 580.00 37.72%
    Last edited by xxdustinxx; 11-27-2011 at 02:05 PM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Your report format was not set up with code tags around it (that's the # icon in the advanced forum editor), so it was torn to smithereens and is useless.

    For this assignment:
    Post up YOUR code, or pseudo code, and just tell us what YOU are stuck on, and USE CODE TAGS! Requests without code tags around the code or formatted text, is routinely ignored, because it can't be grok'ed.

    Your assignment is your assignment, we can't help you with how much work you were given.

    We do know a thing or two about those math equations, however.

    Glad you're getting over the flu.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Adak
    grok'ed.
    ?????

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    1. To understand. Connotes intimate and exhaustive knowledge. When you claim to ‘grok’ some knowledge or technique, you are asserting that you have not merely learned it in a detached instrumental way but that it has become part of you, part of your identity. For example, to say that you “know” LISP is simply to assert that you can code in it if necessary — but to say you “grok” LISP is to claim that you have deeply entered the world-view and spirit of the language, with the implication that it has transformed your view of programming. Contrast zen, which is similar supernal understanding experienced as a single brief flash. See also glark.

    2. Used of programs, may connote merely sufficient understanding. “Almost all C compilers grok the void type these days.”
    I'm not fond of the term either, but the jargon file is there for the rest of us.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Thanks Whiteflags... I'd never heard the term before.

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    24

    other assignment logic

    Also I was wondering if you could check out my logic for this program it is an ISBN reader the requirements are in the attached word file and here is my logic :

    Prototype check digit function

    Define ISBN as 15
    Also indicate Array name index [ISBN]
    Use a while loop in order for the code to be run again with tolower(runagain==y)
    Prompt user to enter isbn#
    Read character string into array using scanf(%s, index)
    Using while loop validate user enter digits using isdigit()
    Using nested for loop convert elements of index[ISBN] using alphanumeric to integer using atoi()
    Then pass converted index[ISBN] to function check_digit(index[])

    Now here is my question how can I make check_digit do what I need it to do without naming each element of the array int a int b etc… and going (a*1)+( b*2)+( c*3). Because the algorithm I found is not working out . I know I need to use modulus 11 %11 I think. Also if you could look at this logic and tell me any problems you see I would appreciate it. I mean I guess I could ask them to enter isbn store each of the using scanf as int a int b int c and never use a function call but if they entered a negative number itr would be an issue.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    24

    The assignment I was first talking about logic and instructions

    Alright here is my logic I do not think I am right but This is my first attempt at the logic also the instructions are in attached word file sorry it is in such huge font

    Logic:
    state variables store num. bagel price etc...

    declare file point to bagel.seq

    use an if statement and fopen to open the bagel.seq
    use printf to state if file does not open
    use else command if file does open
    use printf with formatted conversion identifiers and put store number bagel name bagel price etc.
    use fscanf to print out the information from the bagel.seq file in sequential order under the formatted columns
    use while loop to keep it reading information from the bagel. seq file until end of file
    use fclose to close the file.

    The only thing I am not sure how to do is the math
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You may not be aware of it, but few of us will open a file posted on the forum, because of the various malware that can be attached (especially to a doc file).

    So, I strongly suggest you change the doc file to plain text, and post ONLY the relevant parts that are related to your actual programming problem. You have a HUGE amount of detail that is not boding well for your getting free help, sorry to say.

    My advice is work on it, and condense your questions down to about 3 or 4. Thing is, no one cares HOW you read a string into your program. Just do it as the instructions say, and IF AND WHEN YOU HAVE A PROBLEM DOING IT - then post up about it with the particulars.

    Just backing up a dump truck load of assignment particulars and dumping it on the forum before you've tried to work through them, is not what you want to do.

    Our time is too limited to personally mentor or tutor. Use our help wisely, and do it real quickly. In a matter of a day or two, this post will be going off the front page, go "stale", and probably will not be seen after that. Don't waste your opportunity.


    @Tater didn't grok, "grok"? How's your Scottish brogue? "Do ya nae ken? Had a Scottish guy move in some years back. Brogue was so thick I thought he was talking a foreign language for a month! He was doing well until he picked a fight with a tough Marine - his wife. She bit off part of his ear and sent him to the hospital, no lie.
    Last edited by Adak; 11-28-2011 at 07:33 PM.

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    24
    I am sorry I am new to this... I just wanted to provide all the detail I could because I thought that it would help you and others to provide me with assistance more effectively... sorry I did not mean to take up your time... you said to re post with code tags but I am not sure how to do that so I thought I would just provide the document that contained the same information.... What I was looking for though was comments on my logic and I did not think that anyone could comment on my logic without seeing the specs for the assignment first....Again I will apologize but I would appreciate your comments on my logic...
    Last edited by xxdustinxx; 11-28-2011 at 08:57 PM.

  10. #10
    Registered User
    Join Date
    Oct 2011
    Posts
    24
    Also I am not sure how to condense my question without you seeing the full specs of my program I need to know my professor means when she says this about my logic and 11.7 is referring to figure 11.7 in C How to program it is referring to reading data from a sequential access file... like Account Name Balance with corresponding information under each column and I am unsure about replacing the printf with fprintf to create the bagel.rpt that the bagel.seq is suppose to read into. I do not understand what she means if I replace the printf with
    fprintf I do not see how that will help or I think it will just create an error
    Last edited by xxdustinxx; 11-28-2011 at 09:00 PM.

  11. #11
    Registered User
    Join Date
    Oct 2011
    Posts
    24
    And with the ISBN program I was showing my logic...so you could point me in the right direction or look at where I might have errors.. my professor has told me that I have to work out the logic before I start on the code, so That is what I was trying to do

  12. #12
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by xxdustinxx View Post
    I am lost... I need to create a program that read a file called bagel.seq that contains information about a chain of bagel stores like sales of diffrent types of bagel.
    Can you do the file reading yet?

    Then I have to create a report named bagel. rpt that is suppose to look like a formated table like the one below I just am unsure of how to make the table.
    We have a faq on formatted output you can read.

    and calculate the precentages.
    Percents

  13. #13
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Adak View Post
    @Tater didn't grok, "grok"?
    Obviously not tater, but I have to admire your ability to understand so much completely, and, make it a huge part of your life.

  14. #14
    Registered User
    Join Date
    Oct 2011
    Posts
    24

    Homework Bagel.seq

    I know how to read from the bagel.seq file but I am confused on how to make it write to the bagel.rpt file and then display the information in the form of a report. My teacher said to use fprintf in place of the printf in my logic but that does not make any since to me since that is so early in the program I thought I would need to use the fprintf sometime after I used the fscanf

  15. #15
    Registered User
    Join Date
    Oct 2011
    Posts
    24
    now would I use the fputc command in a while loop to copy the text from the bagel.seq file into the bagel. rpt These are the hints that she gave use, but am not sure which command is more appropriate. and does the fput need to be the fputc or just plain fput. also when I create the . rpt do I create that as a text file in notepad and then have the .seq written into the .rpt file.
    ·fgets and/or fscanf may be useful in reading the file, and fput and/or fprintf may be useful for printing the formatted report.
    ·An array for keeping track of Store Totals may, also, be useful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework Help!!
    By Jdub in forum C Programming
    Replies: 10
    Last Post: 04-24-2010, 02:39 AM
  2. homework
    By misplaced in forum C++ Programming
    Replies: 18
    Last Post: 10-04-2004, 06:56 AM
  3. I want homework!
    By Tynnhammar in forum C++ Programming
    Replies: 9
    Last Post: 09-29-2004, 02:49 PM
  4. ok, yes, I need help with my homework!
    By melee in forum C Programming
    Replies: 5
    Last Post: 09-22-2004, 07:42 AM
  5. Homework help
    By RoD in forum C++ Programming
    Replies: 6
    Last Post: 05-07-2003, 01:53 PM

Tags for this Thread