Thread: Help PLease

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    2

    Help PLease

    I need to do this program for an example workshop but cant get my head around it:

    Program details as follows:

    Input to the program the exam number and computer arch and programming results for 10 people. Three arrays - ExamNo[10], Arch[10] and prog[10] are used to hold these items. The First name and surname of each student should also be entered, concatenated into one string and output to an array called wholename[10]

    We need to check weather the exam numbers are valid. An exam number should consist of 7 digits only Include a function in your solution that will pass in the exam number, determine if the exam number is valid or not and return an appropriate message. only valid exam numbers should be stored in the array ExamNo

    For each of the students, calulatE display the average mark for the class. For the Computer Arch results, find out how many students received below the class average. Find the name of the students with the highest result in each subject. These students' name are to be displayed and told that they will receive a special prize for their outstanding results.

    For programming results, calulate and display standard deviation. I think this is the following steps in order to get it
    1. Calculate the average of the programming results

    2. Calculate the variance(d) by subtracting each result from the average

    3. Square each of these results to get variance squared.

    4. Sum all the variances squared

    5. Divide by the number of numbers

    6. Get the Square root of the result which is the standard Deviation.

    Display the exam number, whole name and both results for all students.

    Let me know what ya think.

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Which parts of the assignment are you having trouble with?

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    No one is going to do your work for you. You need to present a specific part of the problem, and show some code that you have tried.

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    I don't think he was asking us to do his work. I think he was asking us if the steps he wrote down are a good method for doing this.
    Woop?

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Ah. I stand corrected.

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Oh but we can yell at them for not giving a good thread title
    Woop?

  7. #7
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    I find your steps for calculating the std dev a bit hard to follow (just the Eglish reading of it), but it appears as if you have the right formula for it.

    Your solution certainly sounds workable, though. If you know structures/classes, then this would be a good use of a data struct (the group relevant information so you only have one array).
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  8. #8
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Yeah, it seems like a good way to calculate the standard deviation, although if you are still unsure you can always 'google' for it.

    Zach's suggestion of using classes and structs is a good way to go about solving your problem -although, you could probably do the same by using functions and arrays. Less jazzy but still workable.

    Question, when you enter the name of the student, I assume you mean enter the first name as one string and the Surname as another and then concatenate the two, why not just use cin.getline?

    Having said that, you may have not come across this quite yet. Which is probably why you're not using it.

    Good luck though.


  9. #9
    Registered User
    Join Date
    Apr 2005
    Posts
    2
    Right this is what i have done so far any suggestions i am at a kinda standstill now where to go. any help would be very grateful
    Code:
    // Program to show use of  arrays
    #include<iostream.h>
    #include<iomanip.h>
    #include<conio.h>
    #include<ctype.h>
    #include<string>
    
    void input (void);
    void calc (void);
    void display (void);
    void percent (void);
    
    void vvv	(void);
    int checknumb(char[7]);
    
    string fname ;
    string lname;
    const int z = 1;
    string wholename[z];
    
    int results[z], variance[z] ;
    int tot,total;
    char * examn[z];
    int arch[1];
    
    float ave,ave1;
    float perc[10] ;
    
    int main(void)
    {
    
    
        			input();
    
    				percent();
        			calc();
        			display() ;
    
        				 cout<<" Please type in any key to finish"<< endl;
         			getch();
    
        			 return 0;
         							}
    
    
    
       void input (void)
       {
    
    		for (int i = 0; i<z; i++)
       	{
             char studnumber[7];
    
             bool OK = false;
    
             while (!OK)
                {
        		   cout<<" Enter a student number"<<endl;
        		   cin>>studnumber;
    
       		   if (checknumb(studnumber))
                   {
       		      cout<<"This number is valid" <<endl;
                   examn[i]=studnumber;
                   OK = true;
                   }
       		   else
       		      cout<<" Unfortunately this number is invalid"<<endl;
                }
    
             		cout<<"Type in your first name	"<<endl;
             		cin>>fname;
             		cout<<"Type in your last name		"<<endl;
             		cin>>lname;
                   wholename[i]= fname+" "+lname;
       				cout<<" Please type in result for programming "
            			 <<(i+1)<<endl;
         				 cin>>results[i];
    
          			cout<<" Please type in result for architecture "<<(i+1)<<endl;
          			cin>>arch[i];
          			tot+= results[i];
          			total+=arch[i];
          }// close for loop
    
         }   // close function
    
         int checknumb(char code[])
       	{
    
             // confirm string is right length
            if(strlen(code)!= 7)
             	return 0;
    
             //confirm string is all digits
             for (int i = 0; i<7;i++)
             	{
                	if (!isdigit(code[i]))
                   return 0;
                   }
    
             //return -1 if all is Ok
             return -1 ;
             }  // end checknumb
    
    
    void percent(void)
    					{
    				for (int i=0;i<6;i++)
    				{
       			perc[i]=results[i]/total*100;
    
    				cout<<setiosflags(ios::showpoint|ios::fixed)
       			<<setprecision(2)<<perc[i]<<endl<<endl;
      						 }
     				}
    
    
        			void calc (void)
       			{
    				ave = tot/z;
         			 ave1 =total/z;
    
         			for (int i = 0; i <z;i++)
         			{
          		variance[i] = results[i] - ave ;
            				 }
    
             		 }
    
         void display (void)
    
         {
         			  //	cout<<"First Name	+ Last Name	"<<wholename[z]<<endl;   */
    
    
          			cout<<"\n\nTotal of Programming	"<<tot<<endl;
          			cout<<"\n\nTotal of Arch	"<<total<<endl;
    					cout<<"\nAverage of results of Programming	"<<setiosflags(ios::showpoint|ios::fixed)<<setprecision(2)<<ave<<endl;
         			   cout<<"\nAverage of results Of Arch	"<<setiosflags(ios::showpoint|ios::fixed)<<setprecision(2)<<ave1<<endl;
          			cout<< "\n\n Results	" << setw(20)<<"Variance"<<endl;
    
          for (int h = 0; h<z;h++)
       	{
          	cout<<results[h]<<setw(20)<<variance[h]<<endl;
             }
    
               }
    //
    Code:
    // Program to show use of  arrays
    Last edited by nickyjoe; 04-21-2005 at 03:52 PM.

  10. #10
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Your original post says write a program showing the

    results for 10 people
    Obviously, this is your next plan of action.

  11. #11
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Oh you've done that:

    You should have set 'const int z =10' though.

    Now write a function that counts how many students got below the class average. Then write a function that returns the name of the student with the highest score.
    Code:
    int largest=0;
    
     for (int i=0; i<10; i++)
    {
      if(student[i]>largest)
      {
        largest=student[i];
      }
    }
    or something

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well you could work on your indentation skills - that last post was a mess.
    Or configure your text editor to only use spaces for indentation - mixing spaces and tabs really sucks on a message board. Spaces mean everyone sees what you see, not what your super-clever editor manages to tidy up for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed