Theme Graphic
Theme Graphic

c++ progming

projek and the assignment and so one. all the c++ progming and codes and source.

Subscribe

Author

Archive

Tags

Posted on Saturday, March 10, 2012 at 12:21 AM

Projek


hey!!! guy can u help me to fix this solution....

Write a program using array to enter test marks for students in a class. Use your own defined array size with a minimum of FIVE (5) students. The students are required to do THREE (3) tests in a semester.

there are 4 function , call the following functions by passing the array:

(i) A function to input all information. (ii) A function to calculate the average score for each student and the average score for the class. Find the student with highest and lowest average score. (iii) A function to find students who score lower than 50 marks. (iv) A function to display all the information. The information should be displayed in a proper format.

  1. include <iostream>
using namespace std;

const int NUM_NAMES =5; //how many occurances const int NAMESIZE = 11; //how long names can be, 10 letters const int NUM_TESTS = 3; //how many tests char name[NUM_NAMES][NAMESIZE]; //two-dimensional name array char grade[5]; //grade letter for each student array double testscore[NUM_NAMES][NUM_TESTS]; //test score for each student double average[5]; //average for each student array

//function prototype void calcdata(int, double[][NUM_TESTS]);

//start of main int main() {



cout << "Enter the student's name. \n"; for (int count = 0; count < NUM_NAMES; count++) { cout << "Student " << (count +1) <<": "; cin >> name[count]; } for (int student = 0; student < NUM_NAMES; student++) { for (int testnum = 0; testnum < NUM_TESTS; testnum++) { cout << "what is the test score for " << name[student]; cout << " for test:" << testnum+1<< endl; cin >> testscore[student][testnum];

while (testscore[student][testnum] < 0 || testscore[student][testnum] > 100) { cout << "Please enter a number between 0 and 100" << endl; cin >> testscore[student][testnum]; cout << endl; } } }

//call to function calcdata calcdata(NUM_NAMES, testscore);

system("Pause");

return 0; } //end of main

void calcdata(int NUM_NAMES, double testscore[][NUM_TESTS]) { double total; //get each students average score for (int row = 0; row < NUM_NAMES; row++) { //set the accumulator. total = 0;

//sum a row for (int col = 0; col < NUM_TESTS; col++) total += testscore[row][col];

//get the average average[row] = total / NUM_TESTS;

//get the grade if (average[row] < 60) grade[row] = 'F'; else if (average[row] < 70) grade[row] = 'D'; else if (average[row] < 80) grade[row] = 'C'; else if (average[row] < 90) grade[row] = 'B'; else if (average[row] < 100) grade[row] = 'A';

}



for (int i = 0; i < 5; i++) cout << "Student: " << name[i] <<" average: " << average[i] <<" grade: " << grade[i] << endl;



}
Tags: None
Bookmark: Submit To Digg Submit To reddit Submit To del.icio.us Bookmark With StumbleUpon Bookmark With FaceBook Bookmark With Google Bookmarks   Share: Share By Email By Email

0 comments on "Projek"
No comments posted yet.

Leave A Comment
Subject:


Comment:
   Bold Italic Underline          Code Link Image Horizontal Rule


Because you do not have or are not logged in to your Programmer's Heaven account, please enter your name.

Name:


To help prevent comment SPAM, please enter the magic code '214' in the box:




Posting Rules
Please follow these rules when posting comments on blog posts.
  • Do not post anything that is racist, hate speech or of a sexual or adult nature.
  • Do not post or link to anything that infringes copyrighted laws.
  • Posting about security or legal topics is fine so long as you are not glorifying or encouraging people to perform illegal activities.
  • Both the author of this blog and the Programmer's Heaven administrators may delete any inappropriate comments without notice at their own discretion.
 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.