Ok, so I have to write this program that reads #'s into an array, such as grades...
The program must have:
* Read and Print the Numeric Grades
* Declare an array of characters to store the character grades associated w/ the numeric grades
* Translate the numeric grades into letter grades w/ an if-else or a switch statement in an array
* Then it has to print the above results w/ the array index, numeric grade, and letter grade.

How the heck do I incorporate the last 2 steps?
This is what I have so far...
How do you declare a character array? Thanks for the suggestions in advance... =/

# include <iostream>
 # include <iomanip>
 using namespace std;
 
 const int MAXSIZE = 25; //global constant
  
 // function prototypes
  void getlist (int [], int&); 
  void putlist (const int [], int); 
  void find_grades (const int [], int, char []); 
  void print_grades(const int [], const char [], int); 
  
  int main ()
  {
      int list [MAXSIZE];
      int num_grades;
                  
      getlist (list, num_grades);
      putlist (list, num_grades);
      
         
           
           system ("pause");
           return 0;
  }
         
  void getlist (int list [], int &num_grades)
  {
  cout << "How Many Grades Will You Be Entering???:  ";
  cin >> num_grades;
  
  int i; //controls loop
  
  for (i = 0; i < num_grades; i++)
      {
             cout << "Please Enter A Grade:   " << endl;
             cin  >> list [i];
      } 
  }// End of getlist
  
  void putlist (const int list [], int num_grades)
  {
       cout << "Grades" << endl;
       
       for (int i = 0; i < num_grades; i++)
       cout << i << " " << list [i] << endl;
           
  }// End of putlist

Recommended Answers

All 4 Replies

[100 | 95 | 85 | 50 | 91]  //read into this int array (show here illustratively)

//use a function to translate (your if/else construct goes here)

['A' | 'A' | 'B' | 'F' | 'A']  //your new array

A char array is just an array of characters, so char grades[MAXSIZE];

void putlist (const int list [], int num_grades)  {       cout << "Grades" << endl;        for (int i = 0; i < num_grades; i++)       cout << i << " " << list [i] << endl;   }// End of putlist# include <iostream>
 # include <iomanip>
 using namespace std;

 const int MAXSIZE = 25; //global constant

 // function prototypes
  void getlist (int [], int&); 
  void putlist (const int [], int); 
  void find_grades (const int [], int, char []); 
  void print_grades(const int [], const char [], int); 

  int main ()
  {
      int list [MAXSIZE];
      int num_grades;

      getlist (list, num_grades);
      putlist (list, num_grades);



           system ("pause");
           return 0;
  }

  void getlist (int list [], int &num_grades)
  {
  cout << "How Many Grades Will You Be Entering???:  ";
  cin >> num_grades;

  int i; //controls loop

  for (i = 0; i < num_grades; i++)
      {
             cout << "Please Enter A Grade:   " << endl;
             cin  >> list [i];
      } 
  }// End of getlist

  void putlist (const int list [], int num_grades)
  {
       cout << "Grades" << endl;

       for (int i = 0; i < num_grades; i++)
       cout << i << " " << list [i] << endl;



  }// End of putlist

Ok, so I have to write this program that reads #'s into an array, such as grades...
The program must have:
* Read and Print the Numeric Grades
* Declare an array of characters to store the character grades associated w/ the numeric grades
* Translate the numeric grades into letter grades w/ an if-else or a switch statement in an array
* Then it has to print the above results w/ the array index, numeric grade, and letter grade.

How the heck do I incorporate the last 2 steps?
This is what I have so far...
How do you declare a character array? Thanks for the suggestions in advance... =/

# include <iostream>
 # include <iomanip>
 using namespace std;
 
 const int MAXSIZE = 25; //global constant
  
 // function prototypes
  void getlist (int [], int&); 
  void putlist (const int [], int); 
  void find_grades (const int [], int, char []); 
  void print_grades(const int [], const char [], int); 
  
  int main ()
  {
      int list [MAXSIZE];
      int num_grades;
                  
      getlist (list, num_grades);
      putlist (list, num_grades);
      
         
           
           system ("pause");
           return 0;
  }
         
  void getlist (int list [], int &num_grades)
  {
  cout << "How Many Grades Will You Be Entering???:  ";
  cin >> num_grades;
  
  int i; //controls loop
  
  for (i = 0; i < num_grades; i++)
      {
             cout << "Please Enter A Grade:   " << endl;
             cin  >> list [i];
      } 
  }// End of getlist
  
  void putlist (const int list [], int num_grades)
  {
       cout << "Grades" << endl;
       
       for (int i = 0; i < num_grades; i++)
       cout << i << " " << list [i] << endl;
           
  }// End of putlist
void putlist (const int list [], int num_grades)
  {
       cout << "Grades" << endl;
       
       for (int i = 0; i < num_grades; i++){

         cout << i << " " << list [i] << " ";

         if (list[i] > 95) cout << "A" << endl;
         else if (list[i] > 90) cout << "A-" << endl;
         else if (list[i] > 85) cout << "B+" << endl;
         //... 
         else cout << "F double minus" << endl;
       }

  }

-Greywolf

Thanks! I kind of thought that, but it wouldn't complile, so I will do some adjustments iaw your suggestion and try again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.