Thread: PROGRAM MENU, urgent, please help!

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    2

    PROGRAM MENU, urgent, please help!

    My teacher wanted me to write 3 small programs, one was a program that calculates average rainfall for example. The hard part for me right now is also the most important...My main program is supposed to display a menu with the 3 choices (the 3 smaller programs) for you to select and then that operation runs, and repeat each operation over and over again until the user enters 0, which causes the program to terminate. Here's what the example she gave me looks like:

    Choices:

    1) Average Rainfall
    2) Mileage Calculator
    3) Enough Gas
    Enter Your Choice (or 0 to Quit):

    I'm currently on the control flow section of cprogramming for beginners...this is my weekly assignment due at midnight tonight!!! Any help would be super right now, i'm really lost, i understand programs that let you type a certain number which results in something being printed...but how do you get it so that an entire program runs? Do you just save the 3 seperate programs as .c and then you just direct it to the .c file name? I don't remember her saying anything like that though, or is it something simplier like a switch statement or something? Can you guys give me a basic format of what it should look like...

    Thanks guys, hopefully someone will save my buns tonight...

    -Anfernee Witherspoon, Jr.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    just write a function for each option (mileage calc or whatever) and then call it with the correct arguments in a switch statement.
    http://uk.geocities.com/ca_chorltonkids

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    First, try to understand this... then take a minute to learn about the search feature of this board.

    You'll find that most questions have already been asked, maybe not in the same way, but even so, you can get your answer from someone elses conversation.

    As you're new, here's a helping hand. It's a search for the word menu. Some of the code examples aren't the best, but they'll get you started.

    >>Do you just save the 3 seperate programs as .c and then you just direct it to the .c file name?
    Porbably not.

    >>something simplier like a switch statement or something?
    Yes, thats more like it
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Well the lesson here is not to procrastinate. Hope you'll know better next time. Actually it's easier said than done

    Hehe, at least he didn't come screaming in here saying it's due in 5 minutes.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    #define c case
    #define f fgetc(stdin))
    #define i int
    #define m main(
    #define p printf(
    #define r return
    #define s switch(
    #define t break;
    #define v void
    #define x );
    
    #include <stdio.h>
    v a1(v){p
    "Wheee"x}
    v a2(v){p
    "Ooooh"x}
    v a3(v){p
    "Aaaah"x}
    i m v){ p
    		"I\'m a lazy bastard. Please help me.\n"
    		"\t1 - If you're lazy.\n"
    		"\t2 - If you should have done this earlier.\n"
    		"\t3 - If you'll end up doing the same thing with your next assignment.\n"
    	x
    	s
    	f
    	{
    		c'1':a1();t
    		c'2':a2();t
    		c'3':a3();t
    	}
    	r 0;
    }
    Don't say I never gave you anything.

    Quzah.
    Last edited by quzah; 09-26-2002 at 05:45 PM.
    Hope is the first step on the road to disappointment.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    LMFAO!!!!


    That's got to go on the FAQ!!!!!

  7. #7
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    "\t4 - If quzah has too much time on his hands.\n"

    Wheee Ooooh Aaaaah.

    hehe, the poor guy's gonna cry around midnight
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Cshot
    "\t4 - If quzah has too much time on his hands.\n"

    Wheee Ooooh Aaaaah.

    hehe, the poor guy's gonna cry around midnight


    I thought you guys would appreciate that.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    First, try to understand this... then take a minute to learn about the search feature of this board.
    lol, the hammer falls and the smart-questions link appears once again Somehow I knew that was gonna happen.

    **EDIT**
    LOL I just read through that code again... I think quzah doesn't deserve the pay he gets for his job, if that's what he spends his time doing

    **EDIT 2**
    Hmm, there should be a "Humorous Code" sticky on the general discussion forum
    Last edited by Hunter2; 09-26-2002 at 08:43 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Wink

    I think the point all the previous posters are trying to say is that:

    Procrastination on your part does not constitute an emergency on our part.

    I teach programming- big hint --- Start working on the program as soon as you get it. It will save you alot of headaches later on.

    Also, the program she gave you is relatively easy look in your textbook at similar programs to help you and try to logically plan your actions.

    When you have attemped to code the program post it and we will help- if you use code tags!!!!!


    Mr. C.

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    2

    1-8-7

    are all computer nerds that anal-retentive or is just because you can't get a date with your ugly-looking faces?


    if you don't want to help, then don't reply, much less criticize or judge someone...its funny how this situation would be a little different if we were face-to-face and your quivering little dick showed a some respect.


    anyways A FRIEND helped me out with a simple explaination, so thanks for nothing.


    <moderated comment>
    -Anfernee Witherspoon, Jr.

  12. #12

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: 1-8-7

    Originally posted by Anfernee001
    are all computer nerds that anal-retentive or is just because you can't get a date with your ugly-looking faces?
    Are all lazy people so rude and ungrateful? I answered your question. You just didn't like my answer. My code is perfectly working, valid C code. Don't blame me if your feeble mind can't understand it.


    Originally posted by Anfernee001
    if you don't want to help, then don't reply, much less criticize or judge someone...its funny how this situation would be a little different if we were face-to-face and your quivering little dick showed a some respect.
    No, if this were face to face, you'd have heard me say: "Give me a ****ing break. Do it yourself, you lazy ****er." Instead, since it wasn't, I took a couple of minutes and wrote you an answer. Again, it's not my fault you're too stupid to understand the code.


    Originally posted by Anfernee001
    anyways A FRIEND helped me out with a simple explaination, so thanks for nothing.
    Yeah I bet they helped you out. You mean they did it for you. That's really helping. I guess you can't treat a dumb ass new tricks.

    Quzah.
    Hope is the first step on the road to disappointment.

  14. #14
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Anfernee001, don't take it personally that you were asked to read a couple of others pages before posting your message. If you take a short while to learn what to ask and how, you'll find that people are more than willing to help you out.

    And don't resort to offensive stuff... in the end, it just ain't worth it
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  3. Enistine program
    By Mac_the vamp in forum C Programming
    Replies: 2
    Last Post: 11-11-2002, 10:56 AM
  4. c++ program with a button menu
    By quakegod in forum C++ Programming
    Replies: 0
    Last Post: 01-07-2002, 01:09 AM