This is the program that I made

// Chapter 5, Programming Challenge 8: Math Tutor
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
   int num1,          // The first random number
       num2,          // The second random number
       choice,        // The user's choice of problem
       studentAnswer, // The student's answer
       correctAnswer; // The correct answer

   // Seed the random number generator.
   srand(time(0));

   do
   {  // Display the menu and get a choice.
      cout << "\tMath Tutor Menu\n";
      cout << "------------------------------\n";
      cout << "1. Addition problem\n";
      cout << "2. Subtraction problem\n";
      cout << "3. Multiplication problem\n";
      cout << "4. Division problem\n";
      cout << "5. Quit this program\n";
      cout << "------------------------------\n";
      cout << "Enter your choice (1-5): ";
      cin  >> choice;

      // Validate the choice.
      while (choice < 1 || choice > 5)
      {
         cout << "The valid choices are 1, 2, 3, "
              << "4, and 5. Please choose: ";
         cin >> choice;
      }

      // Produce a problem.
      switch (choice)
      {
      case 1:  // Addition problem
               // Generate two random numbers in
               // the range 1 - 500.
               num1 = 1 + rand() % 500;   
               num2 = 1 + rand() % 500;

               // Calculate the correct answer.
               correctAnswer = num1 + num2;

               // Display the problem.
               cout << "\n\n";
               cout << "  " << setw(4) << num1 << endl;
               cout << " +" << setw(4) << num2 << endl;
               cout << "  " << "----"  << endl;
               cout << "   ";
               break;

      case 2:  // Subtraction problem
               // Generate two random numbers in
               // the range 1 - 999.
               num1 = 1 + rand() % 999;   
               num2 = 1 + rand() % 999;

               // Make sure num2 <= num1...
               while (num2 > num1)
                  num2 = 1 + rand() % 999;

               // Get the correct answer.
               correctAnswer = num1 - num2;

               // Display the problem.
               cout << "\n\n";
               cout << "  " << setw(4) << num1 << endl;
               cout << " -" << setw(4) << num2 << endl;
               cout << "  " << "----"  << endl;
               cout << "   ";
               break;

      case 3:  // Multiplication problem
               // Generate two random numbers. The first in
               // the range 1 - 100, the second in the
               // range 1 - 9.
               num1 = 1 + rand() % 100;   
               num2 = 1 + rand() % 9;

               // Calculate the correct answer.
               correctAnswer = num1 * num2;

               // Display the problem.
               cout << "\n\n";
               cout << "  " << setw(4) << num1 << endl;
               cout << " *" << setw(4) << num2 << endl;
               cout << "  " << "----"  << endl;
               cout << "   ";
               break;

      case 4:  // Division problem with no remainder
               // Generate a single digit divisor.
               num2 = 1 + rand() % 9;

               // Generate a number that is a multiple
               // of num2...
               num1 = num2 * (rand() % 50 + 1);

               // Calculate the correct answer.
               correctAnswer = num1 / num2;

               // Display the problem.
               cout << "\n\n";
               cout << "  " << num1 << " / " << num2 << " = ";
               break;

      case 5:  // The user chose to quit the program.
               cout << "Thank you for using Math Tutor.\n\n";
               break;
      }

      // If student selected a problem, get and evaluate the answer. 
      if (choice >= 1 && choice <= 4)
      {
         cin  >> studentAnswer;
         if (studentAnswer == correctAnswer)
            cout << "\n\nCongratulations! That's right.\n\n";
         else
            cout << "\n\nSorry, the correct answer is " << correctAnswer
                 << ".\n\n";
      }
   } while (choice != 5);  // Loop again if student did not choose to quit.
    return 0;
}

The assignment is to modify it so these things are included:

Here is the instruction for my assignment

  1. Gives instructions
  2. Displays previous user’s name and score from file
  3. Prompts for the current user’s name
  4. Provides a menu of math choices (e.g., +. -, *, /), plus exit
  5. Asks users how many questions they want to answer
  6. Asks user for highest number to use
  7. Displays appropriate math questions with random numbers
  8. Keeps track of right and wrong answers
  9. Provide at least 10 randomly chosen correct and incorrect answers for feedback
  10. Gives feedback on how many questions answered and percent right for that group
  11. Returns to menu for possible additional problems
  12. When exit chosen shows grand total statistics – correct, attempted, and percent right
  13. Writes name and results to file
  14. When running again displays name and results of last person to use the program
  15. Break program into appropriate functions
  16. Write and use data validation functions in a private library of your creation that includes generic functions for getString, getInt, and getFloat.

I don't know what to do and I'm compeletely lost.

Well, the first part (display user instructions) seems straightforward; simply write a function that displays the instruction message. While you can probably hard-code the instructions and get credit for it, I would recommend storing them in a data file which the program can read at initialization.

BTW, part four is already in the code (lines 21-29), though separating it out as a function would be advisable. If you had written this yourself, you would know this; but this has all the earmarks of a program written by an instructor as a skeleton which the students are expected to expand upon.

Oh, and while it is not strictly relevant, if you have a compiler and library that supports (part of) C++11, you may be able to replace srand() and rand() with default_random_engine and uniform_int_distribution<int> objects from the <random> library to get a less biased distribution of numbers (the rand() %n method has an inherent bias towards the lower part of the range, IIRC).

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.