Answer to Question #261674 in HTML/JavaScript Web Application for Misha

Question #261674

Hi, I am developing a judging system for the upcoming beauty pageant at school. I am using Visual Studio Code editor, with a firebase framework. I'm also using HTML, Javascript. And I'm using Cloud Firebase database, the free trial. My question is how do I create a system that will allow users to enter multiple scores for one contestant but assume that there will be at least one score entered and average is calculated for each contestant. The scores must be submitted to the database and determine the winner with the highest score and the top 3. Please help me and submit answer to my Email plz.


1
Expert's answer
2021-11-05T17:22:01-0400
#include <stdio.h> 
 
void drawLine( int len ) { int k; for( k=0; k<len; k++ ) printf( "-" ); printf( "\n" ); } 
 
const int MAX = 5; 
 
typedef struct { 
    char studentName[25]; 
    float sub1; 
    float sub2; 
    float sub3; 
} Student; 
 
 
int main () { 
    Student s[MAX]; 
    int i, k; 
    float total, average; 
 
    for( i=0; i<MAX; i++ ) { 
        drawLine( 35 ); 
        printf( "Enter details for student %d:\n", i+1 ); 
        drawLine( 35 ); 
        printf( "Enter student name : " ); 
        fgets( s[i].studentName, 25, stdin ); 
        strtok( s[i].studentName, "\n" ); 
        printf( "Enter score for subject 1 : " ); 
        scanf( "%f", &s[i].sub1 ); 
        printf( "Enter score for subject 2 : " ); 
        scanf( "%f", &s[i].sub2 ); 
        printf( "Enter score for subject 3 : " ); 
        scanf( "%f", &s[i].sub3 ); 
        printf( "\n" ); 
        fflush( stdin ); 
    } 
 
    printf( "\n\n" ); 
 
    drawLine( 100 ); 
 
    printf( "List of all students\n" ); 
 
    drawLine( 100 ); 
 
    printf( "%-25s %8s %8s %8s %8s %8s\n", 
           "STUDENT NAME", "SUB-1", "SUB-2", "SUB-3", 
           "TOTAL", "AVERAGE" ); 
 
    drawLine( 100 ); 
 
    for( i=0; i<MAX; i++ ) { 
        printf( "\n" ); 
        total = ( s[i].sub1 + s[i].sub2 + s[i].sub3 ); 
        average = total / 3; 
        printf( "%-25s %8.2f %8.2f %8.2f %8.2f %8.2f", 
               s[i].studentName, s[i].sub1, s[i].sub2, s[i].sub3, 
               total, average ); 
    } 
 
    printf( "\n\n" ); 
    drawLine( 100 ); 
 
    return 0; 
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS