banner



How To Write A Java Progarm That Asks Number Of Female And Male Registered In Class

  1. #1

    Makara is offline

    Registered User Makara's Avatar


    Count number of male person and female students?

    Hello experts,
    I accept this exercise where, too everything else, I need to count the numbers of male students and number of female students. How do I do that?
    Thanks


  2. #2

    stahta01 is offline

    Registered User


    "...a computer is a stupid machine with the ability to do incredibly smart things, while figurer programmers are smart people with the ability to do incredibly stupid things. They are,in brusque, a perfect match.." Bill Bryson


  3. #3

    camel-man is offline

    Registered User camel-man's Avatar


    use if statements like stahta01 says, and keep a 2 seperate variables representing male and female person students and then increment them when needed


  4. #4

    Makara is offline

    Registered User Makara's Avatar


    Quote Originally Posted by camel-human View Post

    use if statements like stahta01 says, and go on a ii seperate variables representing male and female students then increment them when needed

    This is what I did so far! When I run it, it comes out with a bulletin ".exe has stopped working". I realized the problem is somewhere in the second office.

    Code:

    void dataIn(FILE *infile, double average, studenT stud[N], char male, char female)
    Just what exactly I don't see. Whats wrong?

    Lawmaking:

    #include <stdio.h> #include <string.h> #include "genlib.h" #include "simpio.h"  #ascertain N 100 typedef struct {     char name [30];     int average; }studenT;  void File(FILE*infile, FILE*outfile); void dataIn(FILE *infile, double average, studenT stud[N], char male, char female); main() {     FILE * infile, *outfile;     char proper noun[fifteen], lastname[25], male, female person;     double average;     educatee stud[North];     File(infile, outfile);     dataIn(infile, average, stud, male, female);     system("PAUSE"); }  void File(FILE*infile, FILE*outfile) {     char filein[thirty], fileout[30];     while(TRUE)     {         printf("Give the input file name: ");         gets(filein);         infile = fopen(filein,"r");         if (infile != Goose egg)         {             suspension;         }         printf("Can't open %s\n", filein);     }     printf("Give the output file name: ");     gets(fileout);     outfile = fopen(fileout, "westward"); } void dataIn(FILE *infile, double average, studenT stud[N], char male, char female) {     int i, nscan, mcount, fcount;     double marks[68];     char name[15],lastname[25], termch;     mcount = 0;     fcount = 0;     while(TRUE)     {         nscan = fscanf(infile, "%fifteen[^,], %25[^,], %68g, %c", name, lastname, marks, &termch);         if(nscan == EOF)break;         if(nscan != 4 || termch != '\north')         printf("Error\due north");          if (average >= 10);         {             strcpy(stud[mcount].proper noun, name);             stud[mcount].average = average;             mcount++;         }     } }


  5. #v

    stahta01 is offline

    Registered User


    In club to modify the value of a parameter passed to a part you lot must laissez passer information technology using a pointer.
    This applies to pointer you wish to change.

    Lawmaking:

    void File(FILE*infile, FILE*outfile);
    Needs to be changed.
    One possible way is

    Code:

    void File(FILE**infile, FILE**outfile);
    Tim S.

    "...a reckoner is a stupid motorcar with the ability to practise incredibly smart things, while computer programmers are smart people with the power to practise incredibly stupid things. They are,in brusk, a perfect lucifer.." Pecker Bryson


  6. #6

    Makara is offline

    Registered User Makara's Avatar


    Cheers, but nevertheless I need help with the 2d function.

    Code:

    void dataIn(FILE *infile, double average, studenT stud[N], char male, char female) {     int i, nscan, mcount, fcount;     double marks[68];     char name[15],lastname[25], termch;     mcount = 0;     fcount = 0;     while(TRUE)     {         nscan = fscanf(infile, "%15[^,], %25[^,], %68g, %c", name, lastname, marks, &termch);         if(nscan == EOF)pause;         if(nscan != 4 || termch != '\north')         printf("Error\northward");          if (average >= 10);         {             strcpy(stud[mcount].name, name);             stud[mcount].average = boilerplate;             mcount++;         }     } }


  7. #7

    MK27 is offline

    spurious conceit MK27's Avatar


    Lawmaking:

                          nscan = fscanf(infile, "%15[^,], %25[^,],                      %68g, %c", proper name, lastname, marks, &termch);
    That should be %lg (or lf) for a double. I don't recollect there is a point in using a max length (68) as the value will be truncated regardless.


Source: https://cboard.cprogramming.com/c-programming/145224-count-number-male-female-students.html

Posted by: randallextelown67.blogspot.com

0 Response to "How To Write A Java Progarm That Asks Number Of Female And Male Registered In Class"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel