By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,604 Members | 1,414 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,604 IT Pros & Developers. It's quick & easy.

Help with C++

P: 1
Hello to all is there anyone who could help me figure out why my program will not compile. This is my assignment but I have also included my work and I am getting a error that says (C1083)

Problem 1: Create a Student Class (worth all 100 points)
This problem will require you to create a Student class and a C++ main function to test it. The Student class will need variables for the student id, student name and an array for grades. Luckily, we know that each student will only have 10 grades, so an array with 10 elements will hold all the studentís grades.

The Student class will also need a mutator method to set the grades, and a method to calculate the average of the grades.

In the C++ main function, you will need to create two instances of the Student class for the two students, which I need averages for.

Here are the studentsí grades (you can just hard code them if you want):
Student 1 95 78 26 92 27 46 89 83 78 90
Student 2 100 98 97 67 59 100 98 76 83 85


The file should be named so:

<Your User Name>A8P1.cpp

For this assignment you will only need to turn in the source file (i.e. the cpp file).

Submit the assignment in the Digital Drop Box. Please remember to label this assignment <your user name>A8P1.cpp in the Digital Drop Box.

BONUS 1: (this is optional but will give you 5pts to add to any exam or assignment grade)
Write methods that will return the studentís lowest grade and highest grade and then display them. For Example:

Student Lowest Highest
--------------------------------------------------
1 26 95
2 59 100


My Work

Expand|Select|Wrap|Line Numbers
  1. #include "stdafx.h"
  2. #include "employee.h"
  3.  
  4. Student::Student( )
  5.  
  6. {
  7.  
  8.       setStudentNumber( 0 );
  9.  
  10.       setStudentName( "Suzie Cue" );
  11.  
  12.       setStudentsgrades[ 10 ];
  13.  
  14. }
  15.  
  16. Student::Student( int StudentNumber, string StudentName)
  17.  
  18. {
  19.  
  20.       setStudentNumber( StudentNumber );
  21.  
  22.       setStudentName( StudentName );
  23.  
  24.       setStudentsgrades[ Testgrades ];
  25.  
  26. }
  27.  
  28. double Student::ComputeAverage( double testsTaken )
  29.  
  30. {
  31.  
  32.       double Testgrades = 0.0;
  33.  
  34.       for (int i = 0; i<testsTaken; i++)
  35.  
  36.       Testgrades += Testgrades[i];
  37.  
  38.       return Testgrades /= testsTaken;
  39.  
  40. }
  41.  
  42. double Student::getStudentNumber( )
  43.  
  44. {
  45.  
  46.       return iStudentNumber;
  47.  
  48. }
  49.  
  50. void Student::setStudentNumber( int StudentNumber )
  51.  
  52. {
  53.  
  54.       iStudentNumber = StudentNumber;
  55.  
  56. }
  57.  
  58.  
  59. string Student::getStudentName( )
  60.  
  61. {
  62.  
  63.       return this->sStudentName;
  64.  
  65. }
  66.  
  67. void Student::setStudentName( string StudentName )
  68.  
  69. {
  70.  
  71.       this->sStudentName = StudentName;
  72.  
  73. }
  74.  
  75. double Student::getTestgrades( )
  76.  
  77. {
  78.  
  79.       return this->dTestgrades; 
  80.  
  81. }
  82.  
  83. void Student::setStudentsgrades( double testsTaken )
  84.  
  85. {
  86.  
  87.       this->dTestgrades = Testgrades;
  88.  
  89. }
  90.  
  91. int _tmain(int argc, _TCHAR* argv[])
  92.  
  93. {
  94.  
  95.       Student student1;
  96.  
  97.       student1.setStudentNumber( 1 );
  98.  
  99.       student1.setStudentName( "Suzie Cue" );
  100.  
  101.       student1.setStudentsgrades[ 95, 78, 26, 92, 27, 46, 89, 83, 78, 90 ];
  102.  
  103.       Student student2;
  104.  
  105.       student2.setStudentNumber( 2 );
  106.  
  107.       student2.setStudentName( "Laura Ingalls" );
  108.  
  109.       student2.setStudentsgrades[ 100, 98, 97, 67, 59, 100, 98, 76, 83, 85 ];
  110.  
  111.       cout << setfill( '*' ) << setw(40) << "" << endl;
  112.  
  113.       cout << "Student Number " << Student1.getStudentNumber( ) << endl;
  114.  
  115.       cout << "\t\t" << student1.getStudentName( ) << endl;
  116.  
  117.       cout << "\t\tTest average is $ " << std::fixed << std::setprecision( 2 ) <<  student1.ComputeAverage[10] << endl;
  118.  
  119.       cout << setfill( '*' ) << setw(40) << "" << endl << endl;
  120.  
  121.       cout << setw(40) << setfill( '*' ) << "" << endl;
  122.  
  123.       cout << "Student Number " << std::setprecision( 0 ) << student2.getStudentNumber( ) 
  124.  
  125.       << endl;
  126.  
  127.       cout << "\t\t" << student2.getStudentName( ) << endl;
  128.  
  129.       cout << "\t\tTest average is $ " << std::fixed << setprecision( 2 ) <<  student2.Computeaverage [ 10 ] << endl;
  130.  
  131.       cout << setw(40) << setfill( '*' ) << "" << endl << endl;
  132.  
  133.       return 0;
  134.  
  135. }
  136.  
  137.  
  138. int _tmain(int argc, _TCHAR* argv[])
  139. {
  140.     return 0;
  141. }
  142.  
Nov 11 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
Posting the error "(C1083)" is not enough. Without knowing the compiler the number means nothing, even it you post the compiler you are using the number will mean nothing to those people who do not use the same compiler.

As it happens I can see you have used the Microsoft barstardisation of main _tmain and I guess you are using MSVC++

Post the complete error message, highlight the line in your code that you are getting it on.
Nov 12 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.