Jump to content
Sign in to follow this  
dell123

Aku Tertekan Dgn Soalan C++

Recommended Posts

aku tak tau sangat c++ tapi aku kena buat..kena gak memaksakan diri buat...tapi aku tak tahu....aduuii..kalau vb tue boley la...nie projek dia kasi sekali dua vb than c++...arrrgghh mana satu nak ingat...

jadi aku memerlukan member2 yang expert c++ tue kalau boley tolong lah aku kasi contoh pun jadi lah untuk buat program c++ nie nak selesaikan soalan nie..

write a program that allows the user to enter the students name...output:-

->class average

->names of all students whose test scores are below the class average

->highest test score and the name of at studts having the highest score

Share this post


Link to post
Share on other sites

nak contribute sikit

//otai_g[c] properties

#include <iostream>
#include <string>
#define MAX 3 //setkan student kepada 3 org utk memudahkan aku
using namespace std;

void main ()
{
    string name[MAX];
    int i, index=0;
    double score[MAX], average, totalScore=0, highest;

    for (i=0; i<MAX; i++) {
        cout<<"Name : ";
        cin>>name[i];
        cout<<"Score : ";
        cin>>score[i];
        totalScore = totalScore + score[i];
    }

    average = totalScore / MAX;
    cout<<"\nClass average : "<<average<<endl;

    cout<<"\nStudents below the class average"<<endl;
    cout<<"================================"<<endl;

    for (i=0; i<MAX; i++) {
        if (score[i] < average)
            cout<<name[i]<<" with score "<<score[i]<<endl;        
    }

    cout<<"\nStudents the highest score"<<endl;
    cout<<"=========================="<<endl;

    highest = score[0];

    for (i=1; i<MAX; i++) {        
        if (highest < score[i]) {
            highest = score[i];
            index = i;
        }
        
    }

    cout<<name[index]<<" with score "<<score[index]<<endl;
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...