Help!! Due Today!! Family Surgery Prevented me from doing HW

This is a discussion on Help!! Due Today!! Family Surgery Prevented me from doing HW within the C Programming forums, part of the General Programming Boards category; Hey guys, i have been coming around here a while, lurking, getting idea's to help myself with Homework mainly, im ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    7

    Unhappy Help!! Due Today!! Family Surgery Prevented me from doing HW

    Hey guys, i have been coming around here a while, lurking, getting idea's to help myself with Homework mainly, im in C programming in school, but its my first programming course, and i have been doing great so far. However recently my father in law had to have a liver transplant and i have been driving back and forth every other day or so to see in about 2 hours away. this has really hindered my ability to do my homework, i was wondering if any of you would be gracious enough to At least get me started in the right direction ,i dont have time to read a whole chapter and do the work by tonight... If not thats fine i understand.

    Here is my Assignment.

    "1. Create a new program to display product information for cat food. You will use arrays to hold the type (C for Cat, K for Kitten), package size (weight), product ID (SKU), and price. (See table below for data to use in the initializer lists.) The program should calculate and store the price per ounce to allow the user to compare prices.
    Write functions to compute the low (using array notation), average, and high (using pointer notation) values.
    In the main program, display a welcome message and display the product information. Call the functions to display the product information for the products with the lowest and highest price per ounce. Call the function and display the average price per ounce. Allow the user to repeatedly request the display product information based on the product ID.
    Include comments to document each function, its input and output.

    Note: This project demonstrates arrays and pointers in C."


    Code:
    Type    	  Pounds SKU	   Price
    C	          3.50	 66311      6.99
    C	          7.00	 62677      9.99
    C	        16.00	1235303	16.99
    C	          3.50	902829	 6.99
    C	          7.00	902837	10.99
    C	        16.00	1235265	17.99
    C	          3.00	1145568	7.99
    C	          6.00	1145690	10.99
    C	        14.00	1145550	16.99
    C	          3.00	1042629	5.49
    C	          6.00	1042602	9.99
    C	          6.00	1042580	9.99
    C	        15.00	1042599	20.99
    C	          3.15	1052187	7.99
    K	          3.50	146390	6.99
    K	        14.00	1056638	17.99
    Last edited by Die The Villain; 02-16-2011 at 12:19 PM. Reason: Trying to fix table

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Death! Death!!! Death!!!!!!!!!!!!!!!!!!!!!!!! ( You know who said that, and who will! )
    Devoted my life to programming...

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Die The Villain View Post
    However recently my father in law had to have a liver transplant and i have been driving back and forth every other day or so to see in about 2 hours away. this has really hindered my ability to do my homework
    Ask your teacher for an extension... there's no way you're finishing that assignment in one day.
    (I'm sure he will believe your story...)

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    7
    She does not give out extensions due to the fact we go over it in class...

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,496
    Unfortunately, we have a pretty strict homework policy. You wont learn otherwise. There are however, some nice tutorials to help you get things going.

  6. #6
    Registered User
    Join Date
    Feb 2011
    Posts
    7
    I completely understand the homework policy and i can show you some of my previous work to show you i am following along in the class just fine, however, this is a bit of an extenuating circumstance. its not like i just slacked off. and my class is at 6:00pm est its 2:30 now. im running a bit low on time..

  7. #7
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,496
    If you've been following along in the class, then you should have some grasp of the concepts needed to complete this. Start coding furiously and once you get something together, come back. Apart from when I'm eating lunch, I check this thing pretty regularly throughout the work day, and will be happy to help with your assignment, just not do it for you. And sometimes, unfortunate though it may be, you just have to take a crappy grade because of extenuating circumstances.

    But stop begging and get started now! There's still time.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    <<Nothing is tested in this>>

    This should give you some guidelines to write your own, more quickly. Don't just submit this as your program.

    Code:
    #include <stdio.h>
    #define SIZE 16
    
    
    int lowest(double perOunce[]); 
    int highest(double *perOunce); 
    double average(double *perOunce); 
    void showCK(char type[],double weight[],unsigned long sku[],double price[],double perOunce[],char choice); 
    
    int main(void) {
      char type[]={"CCCCCCCCCCCCCCKK"};
      double weight[]={3.5,7.00,16.00,3.50,7.00,16.00,3.00,6.00,14.00,
      3.00,6.00,6.00,15.00,3.15,3.50,14.00};
    
      unsigned long sku[]={66311,62677,1235303,902829,902837,1235265,1145568,1145690,
      1145550,1042629,1042602,1042580,1042599,1052187,146390,1056638};
    
      double price[]={6.99,9.99,16.99,6.99,10.99,17.99,7.99,10.99,16.99, 
      5.49,9.99,9.99,20.99,7.99,6.99,17.99};
    
      double perOunce[SIZE]={0.0}, average1;
      char choice;
      int i, idx, index[SIZE];
    
      for(i=0;i<SIZE;i++) {
        index[i]=i;                       /* set the index up for later sorting */
        perOunce[i] = price[i]/weight[i]; /*calculate and store price per ounce */
      }
      do {
        printf("\n\n\n\n\n\t\t    Welcome to the Cat Food Info Program\n\n");
        printf("\t Today's Cat Foods Are:\n\n");
    
        printf("\t What would You like to See?\n\n");
        printf("\t [L]owest price per ounce of all foods \n\n");
        printf("\t [H]ighest price per ounce of all foods\n\n");
        printf("\t [A]verage price per ounce of all foods\n\n");
        printf("\t [C]at food info only\n\n");        
        printf("\t [K]itten food info only\n\n");
    
        printf("\t Your choice (or Q to quit): ");
        scanf("%c", &choice);
        (void) getchar();                     /* remove newline from input stream */
        if(choice < 'a') choice += 32; /* change choice to lowercase, if it's uppercase */
        else if(choice=='l')
          i = lowest(perOunce);
        else if(choice=='h')
          i = highest(perOunce);
        else if(choice=='a') {
          average1 = average(perOunce);
          printf("%.2lf", average1);
        }
        else if(choice=='c' || choice=='k')
          showCK(type,weight,sku,price,perOunce,choice);
        else
          printf("\n I didn't understand that choice, please enter another\n\n");
    
        if(choice=='l' || choice=='h') 
          printf("  %c  %6.2f  %10lu  %6.2f    %6.2f\n",type[i],weight[i],sku[i],price[i],perOunce[i]);
    
        
      }while(choice != 'q');
    
      return 0;
    }
    double average(double *perOunce) {
      int i;
      double avg;
      for(i=0,avg=0.0;i<SIZE;i++) {
        avg += *(perOunce+i);  /* sum up all prices */
      }    
      avg /= SIZE;           /* divide to get the average */
    
      printf("\n The average price of all our products is: ");
      return avg;
    }
    int highest(double *perOunce) {
      int i, hi;
      double highest;
      for(i=0,highest=*perOunce;i<SIZE;i++) {
        if(*(perOunce+i) > highest)
          hi = i;
      }
    
      printf("\n The highest price per ounce cat food is \n");
      printf(" Type Pounds      SKU     Price  Price Per Pound\n");
      printf(" ===============================================\n");
      return hi;
    }
    int lowest(double perOunce[SIZE]) {
      int i, low;
      double lowest;
      for(i=0,lowest=perOunce[0];i<SIZE;i++) {
        if(perOunce[i] < lowest)
          low = i;
      }
      printf("\n The lowest price per ounce cat food is: \n");
      printf(" Type Pounds      SKU     Price  Price Per Pound\n");
      printf(" ===============================================\n");
      return low;
    }
    void showCK(char type[SIZE],double weight[SIZE],unsigned long sku[SIZE],double price[SIZE],double perOunce[SIZE],char choice) {
      int i;
    
      printf(" Type Pounds      SKU     Price  Price Per Pound\n");
      printf(" ===============================================\n");
      choice -= 32; /* switch it to uppercase letter */
      for(i=0;i<SIZE;i++) {
        if(type[i]==choice)
          printf("  %c  %6.2f  %10lu  %6.2f    %6.2f\n",type[i],weight[i],sku[i],price[i],perOunce[i]);
      }
      printf("\n\t\t    press Enter to Continue");
      (void) getchar();
    }
    Last edited by Adak; 02-16-2011 at 04:21 PM.

  9. #9
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    Quote Originally Posted by Adak View Post
    Don't just submit this as your program.
    Yeah like saying that's going to mean anything to someone who is desperate for exactly what you've just handed them on a silver platter.
    "Here's the keys to my Ferrari, but don't even so much as go anywhere near it".

    The poster has shown no attempt to start the homework and you've probably handed them enough to get a passing mark. That doesn't strike you as having crossed some line?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Before my mom died, she had many major surgeries, and was given the last rites three different times. In her last year, I lost a great deal of time in my senior year of high school, because I was the only family member around to help take care of her.

    It did not strike me as a lie to get help, but I agree with you, it could be exactly that. If so, it was a good one. I did not talk to God over breakfast this morning, so I have no perfect answer for this. Most schools check code for plagiarism with a homework checker program, and this is one of the first sites they scrape.

  11. #11
    Registered User
    Join Date
    Feb 2011
    Posts
    7
    So my teacher was nice enough to, under this one circumstance, grant me an extension till 5:30 today... i came back to post what i have. then i saw Adak's post.
    1. Thank you soo much for helping me with this, i will not use your code copy-pasta style, but i will learn from it.
    2. after running yours.. its soo pretty, mine feels so insignificant and ugly haha :P
    3. Mine still doesnt work as i have it but im gonna use Adaks and i will post back what i have when it works, here is mine now
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    float min (kitty, tom);
    
    int main (void)
    {
        //initializing arrays
        char catType;
        float poundsKitten[]= {3.50, 7.00, 16.00, 3.50, 7.00, 16.00, 3.00, 6.00, 14.00, 3.00, 6.00, 6.00, 15.00, 3.15};
        float poundsCat[]= {3.50, 14.00};
        float priceKitten[]= {6.99, 9.99, 16.99, 6.99, 10.99, 17.99, 7.99, 10.99, 16.99, 5.49, 9.99, 9.99, 20.99, 7.99};
        float priceCat[]= {6.99, 17.99};
        int skuKitten[]= {66311, 62677, 1235303, 902829, 902837, 1235265, 1145568, 1145690, 1145550, 1042629, 1042602, 1042580, 1042599, 1052187};
        int skuCat[]= {146390, 1056638};
    
        //Screen output & Keyboard input also a Tosh.0 and city i live in reference
        printf("\t\t      Save me a nickel, save me a dime\n\t       Jax Bargain CatFood, We'll Do it everytime time!\n\n");
    
        printf("Please Press C for Catfood or K for Kittenfood: ");
        scanf("\n%c", &catType);
    
        //takes Keyboard input and select proper action
        //do while loop commented out do to madness.... sheer madness
        // do
        // {
        if (catType == 'C'|| catType =='c')
        {
            printf("TYPE\t\tPOUNDS\t\tSKU\t\tPRICE");
            printf("\n%c\t\t%.2f\t\t%i\t\t%.2f", catType, poundsKitten, skuKitten, priceKitten);
        }
        else if (catType =='K'|| catType =='k')
        {
            printf("TYPE\t\tPOUNDS\t\tSKU\t\tPRICE");
            printf("\n%c\t\t%.2f\t\t%i\t\t%.2f", catType, poundsCat, skuCat, priceCat);
        }
        else
        {
            printf("Say what? Try that again. C for Cat, K for Kitten");
            scanf("\n%c", &catType);
        }
        // }
        // while (catType == 'C'|| catType =='c'||catType =='K'|| catType =='k');
    
        printf("\n\nand now to find the lowest, average, and high prices.");
        //min function commented out till it can be fixed, need to work more on main
        //min(priceKitten, priceCat);
        return 0;
    }
    
    /*
    float min (float kMin, float cMin)
    {
        int i;
        float kMin[]= {6.99, 9.99, 16.99, 6.99, 10.99, 17.99, 7.99, 10.99, 16.99, 5.49, 9.99, 9.99, 20.99, 7.99};
        float cMin[]= {6.99, 17.99};
        for (i = 0; i < 10; i++)
        {
            if (kitty[i] < kMin)
            {
                kMin = kitty[i];
            }
        }
        printf ("Minimum element in an array : %d\n", kMin);
    
        return 0;
    }
    */

  12. #12
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    Quote Originally Posted by Adak View Post
    Before my mom died, she had many major surgeries, and was given the last rites three different times. In her last year, I lost a great deal of time in my senior year of high school, because I was the only family member around to help take care of her.

    It did not strike me as a lie to get help, but I agree with you, it could be exactly that. If so, it was a good one. I did not talk to God over breakfast this morning, so I have no perfect answer for this. Most schools check code for plagiarism with a homework checker program, and this is one of the first sites they scrape.
    Sorry to hear that. Looks like no harm done though I guess.

    I too have once had circumstances whereby I needed an extension for a valid reason, though I'm not certain I was actually believed.
    I had been working on my final year research paper on my iMac about 10 years ago, and just as I was putting the finishing touches on it the night before it was due, my iMac's power supply died suddenly. After contacting my local apple store I was told that it would take a week to get and install a new power supply. Going to see the Dean I foolishly admitted that yes I did have an old backup copy (about a month old and what student doesn't do most of their work in the last quarter of the time available) and I was given a mere three days to finish starting from that backup copy. Well I was a bit exhausted to do another 3 days with little sleep so in fact I didn't get that much more done and got a poor mark as a result.
    Had they agreed to wait for the repair and get the file off it as-is, then I'm sure would have gotten a far better mark. And it was worth double any other thing I had done that year.
    Last edited by iMalc; 02-17-2011 at 11:27 AM.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  13. #13
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    In a nutshell, life's a beach!
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c++ Payroll Due Today!!!!
    By jbuhrman in forum C++ Programming
    Replies: 2
    Last Post: 02-21-2010, 10:13 AM
  2. C program for Class --- DUE TODAY!!! AHHHH
    By Fr0st2k in forum C Programming
    Replies: 6
    Last Post: 09-22-2004, 03:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21