challenge...???

This is a discussion on challenge...??? within the C Programming forums, part of the General Programming Boards category; im havin trouble with this... Prompt the user for the number of students in the class , and the class ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    10

    challenge...???

    im havin trouble with this...
    Prompt the user for the number of students in the class , and the class name
    For each student in the class get from the user :
    Student's Name
    Student's Gender
    Student's Numeric Grade
    For each student echo out to the screen:
    Student's Name
    Student's Letter Grade
    in the format "John Doe has an A in the class."
    Finally echo out to the screen the Class Summary, which includes:
    Name of the Class
    Average Mean for the Class Grade
    Number of Males in the Class
    Number of Females in the Class
    Average Grade for the Males
    Average Grade for the Females

    i pretty much know how to do each task individually but i cant make one program that does everything....need some help please...

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by kermi3
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:
    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

    Make sure you have a look at the the posting guidelines:
    http://cboard.cprogramming.com/annou...ouncementid=51
    Following the rules will ensure you get a prompt answer to your question.

    Remember, too, that the board has a search facility, a link is at the top of your screen:
    http://cboard.cprogramming.com/search.php
    It will often get you a quicker answer to your questions than waiting for a response to one you have posted.

    It appears that you are posting a homework assignment or other project.

    Please don't ask people to do all your work for you, See the announcement on Homework at the top of all forums to see what is acceptable or PM me. Basically people are happy to help, but they're not going to do it all for you.

    Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.


    On obivous homework questions especially, I like to remind people of the board's ninth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

    Feel free to PM me with any questions.

    Good Luck,

    Kermi3
    Do all that, then try again.

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

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    our teacher told us to join an interactive forum to help because we are beginners this site was recommended to me by other programmers and i was told it gave good feedback...we just have to site the source when we get help from online sources...thanx and please help guys cuz im an obvious newb

  4. #4
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    Hi civiclx97,

    Here at cboard, you will be hard pressed to find a single member who is going to do your homework for you. Before you get any help, you will need to show that you put some effort forth for the problem, and then we will give you help to the best of our knowledge (and believe me, there's a very large knowledge base here at cboard).

    So please, follow quzah's post and then repost with what you've done.

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    this is what i have so far

    #include <stdio.h>

    int main()
    {
    int number_of_students;
    char class_name;
    int numeric_grade;
    char name;
    int class_average;
    int males;
    int females;
    int male_average;
    int female_average;
    int counter;
    int gender;

    printf("How many students in the class:\n");
    scanf("%i", &number_of_students);

    counter>=1;
    number_of_students = 0;

    while (counter <= number_of_students)

    printf("Give students name:\n");
    scanf("%c\n", &name);
    printf("Give numeric grade:\n");
    scanf("%i\n", numeric_grade);


    if (numeric_grade >= 90)
    printf("%c has an A in the class\n",name);
    else if (numeric_grade >= 80)
    printf("%c has a B in the class\n",name);
    else if (numeric_grade >= 70)
    printf("%c has a C in the class\n",name);
    else if (numeric_grade >= 60)
    printf("%c has a D in the class\n",name);
    else
    printf("%c has a F in the class\n",name);

    im not so good with syntax and just started coding like 3 weeks ago...thanks guys

  6. #6
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    show your code (using code tags ),
    First step, follow the above advice, and then indent your code to make it more readable.

    Also, in C++, for every { that you "open", you must "close" it with a }.

    So, if you have:

    Code:
    int main()
    {
    you should have a:
    Code:
    }
    somewhere to match it.

    -----------
    Code:
     counter>=1;
    What exactly is the purpose of that code?
    Last edited by jverkoey; 02-27-2005 at 10:58 PM.

  7. #7
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    im srry i didnt know how to do the code tags....the purpose is to give a teacher a summary of the students along with their grades in a particular class

  8. #8
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    so it looks like this
    Code:
    #include <stdio.h>
    
    int main()
    {
    	
    	int number_of_students;
    	char class_name;
    	int numeric_grade;
    	char name;
    	int class_average;
    	int males;
    	int females;
    	int male_average;
    	int female_average;
    	int counter;
    	int gender;
    
    	printf("How many students in the class:\n");
    	scanf("%i", &number_of_students);
    
    	counter>=1;
    	number_of_students = 0;
    
    	while (counter >= number_of_students)
    	   printf("Give students name:\n");
    	   scanf("%c\n", &name);
    	    printf("Give numeric grade:\n");
    	    scanf("%i\n", numeric_grade);
    	
    	
    	if (numeric_grade >= 90)
                       printf("%c has an A in the class\n",name);
                          else if (numeric_grade >= 80)
    	        printf("%c has a B in the class\n",name);
    	           else if (numeric_grade >= 70)
    		printf("%c has a C in the class\n",name);
    		   else if (numeric_grade >= 60)
    		      printf("%c has a D in the class\n",name);
    		      else
    		         printf("%c has a F in the class\n",name);
    
    	return 0;
    
    }
    this obviously does not answer everything i need for the program but i started to do this and just got stuck...im sorry for being new to the forum and not using the tags but im in desperate need of help

  9. #9
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    Ok, in your code, you have a few statements that (in this case) require the use of a set of curly braces, and I don't see any.

    For example, your while loop does not have any curly braces to go with it, it should be more like so:

    Code:
    while (counter >= number_of_students)
    {
    // code goes here
    }
    Notice that curly braces denote a "block" of code. For the if statements, you need to do the same thing with adding the curly braces to be around all of the code you want to apply to those statements.

    The only time you DON'T need curly braces is if you only have one statement applying to each block. However, in your case I'd suggest just having curly braces around all of your blocks of code for the time being, until you get the feel for your code a bit better.
    Last edited by jverkoey; 02-27-2005 at 11:00 PM.

  10. #10
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    yeah i forgot to put them back in...i originally had them in there but it kept giving me an ongoing list of "enter students name" over and over and over again....i just need help with a setup that will accomplish the goals stated in the first post...i think i can look up in my book how the syntax goes...thanx a lot though i think i can learn a lot here...i just cant fit all that info into one program, what i started was just an attempt at starting it...am i goin in the right direction

  11. #11
    Registered User Scribbler's Avatar
    Join Date
    Sep 2004
    Location
    Aurora CO
    Posts
    266
    First... You're code seems to be C code, not C++ (so maybe this should be moved to the C forum)

    Second, looking at this snippet...
    Code:
    	printf("How many students in the class:\n");
    	scanf("%i", &number_of_students);
    
    	counter>=1;
    	number_of_students = 0;
    From this I'll surmise that you haven't bothered to either pseudo-code your project (or flowchart it, whichever method you're learning). In this example you're asking the user how many students to process, then you reset what they enter to 0.

    Your original statement claims you know how to perform each task individually, which is essentially all you really need do. And from what other replies have pointed out to you, coupled with this example/snippet, I will strongly urge that you start over from scratch. Pseudo Code the entire project first. Each of the individual tasks will stack together like building blocks, and you will alleviate logic problems like I pointed out.

    Do that and I think you will find that you've made it seem to be more difficult than it actually is.
    Last edited by Scribbler; 02-27-2005 at 11:26 PM.

  12. #12
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    ok ill try to psuedocode it...my class is called c++ so im sorry for putting it in the wrong forum... yeah i got that counter and number of students = 0 from an example in our book but i guess that doesnt make much sense... thanx a lot man....any advice is good and much appreciated...keep it comin guys...this helps a beginner out a lot

  13. #13
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    I'm kind of surprised that they call it a C++ course but they don't have you using the standard code:

    Code:
    #include <iostream>
    using namespace std;
    
    
    int main()
    {
        return 0;
    }

  14. #14
    Registered User
    Join Date
    Feb 2005
    Posts
    10
    i think we are starting with C and then moving into C++

  15. #15
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Moved to the C board since this is really C code.

    im srry i didnt know how to do the code tags
    One of the first thing a programmer needs to learn how to do is to read any assignment and help documention completly. In quzah's reply there was a link on how to use code tags. I see you have them now so I congratulate you on that.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. AI Challenge
    By unknown_111 in forum General AI Programming
    Replies: 0
    Last Post: 10-02-2007, 01:18 AM
  2. A Challenge in C++
    By Brad0407 in forum C++ Programming
    Replies: 38
    Last Post: 07-18-2007, 01:56 PM
  3. Programming Challenge (for my school)
    By Ezerhorden in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2006, 06:56 AM
  4. Challenge?
    By Mackology101 in forum C Programming
    Replies: 5
    Last Post: 11-23-2004, 02:30 PM
  5. Requesting a challenge
    By RealityFusion in forum C++ Programming
    Replies: 8
    Last Post: 08-18-2003, 09:24 PM

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