Thread: Math test program

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    2

    Math test program

    Hi, I'm trying to get this code done and I can't figure it out. Some people from another website have been trying to help me but then they just stopped and I have no idea where they were going with this program. It's for a final in my programming class and I'm back in my hometown so I can't go into class to get help. Could someone please take a look at this code and help me it would mean alot this is due in 2 days and I'm really freaking out.

    If you choose this path you will develop a math tutor for grades k - 3 & 4 - 6 (need to understand levels of math skills for each of these levels). This will be a fully functional application that will run as long as the user wants it to run asking them to answer a randomly generated math problem. They must be able to select their level and whether they want to practice - addition, subtraction, multiplication, or division (make sure the program does not allow division by zero! You must keep track of their statistics providing them with a complete report of how well they did after each round - have the program comment on their correctness or incorrectness giving them at least 6 tries before giving them the correct answer. Provide encouraging comments throughout the program (funny is acceptable ).

    Inputs - user name, user level, user enters which equation type they want to practice,
    program should generate the problem based on user entry, display correct or incorrect responses, and allow the user to continue or stop

    Outputs - user statistics ( nice report format) after each round, encouraging comments throughout program execution, and final game comments

    That's the question and here's what I have so far, please please please help me I would apprectiate it alot.

    /////////////////////////


    This is how it now looks btw, no x and y I made those gone and gtwo.

    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
    
    // variables /////////////////////////////////////////////////////////////////////
    
    int grade = 0;
    int mathtype;
    string name;
    int gone rand();
    int gtwo rand();
    int answer;
    int guess;
    
    
    // START ////////////////////////////////////////////////////////////////////
    cout <<" WELCOME TO Katies MATHTEST!!!"<<endl<<endl<<endl;
    cout <<"Please enter your name: "<<endl;
    cin >> name;
    cout <<"and what grade are you in?"<<endl;
    cin >>grade;
    
    
    // Now I need to make an if so it will know which grade to go into///////
    
    
    if (grade <4)
    {
    cout <<"You've selected grades k-3, what would you like to work on?"<<endl;
    cout <<endl<<endl<<endl<<"Addition Division Multiplication Subtraction"<<endl;
    cout << " 1 2 3 4 "<<endl<<endl<<endl;
    
    cin >> mathtype;
    }
    
    
    else
    {
    cout <<"You've selected grades 4-6, what would you like to work on?"<<endl;
    cout <<endl<<endl<<endl<<"Addition Division Multiplication Subtraction"<<endl;
    cout << " 1 2 3 4 "<<endl<<endl<<endl;
    
    cin >> mathtype;
    }
    //////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////
    //////////////////////////////////////////
    //////////////////////////
    ////////////
    ////
    
    if (mathtype == 1)
    {
    
    
    cout<<"You chose Addition, here's question 1 of 5"<<endl;
    gone + gtwo = answer;
    cout<<"What is "<<gone<<"plus "<<gtwo<<endl;
    cin>>guess;
    
    if (guess == answer)
    {
    cout<<"That's right!"<<endl;
    }
    
    else
    {
    cout<<"Sorry that's not right, please guess again"<<endl;
    }
    
    }
    
    
    
    
    
    
    
    if (mathtype == 2)
    {
    cout<<"You chose Division"<<endl;
    }
    
    if (mathtype == 3)
    {
    cout<<"You chose Multiplication"<<endl;
    }
    
    if (mathtype == 4)
    {
    cout<<"You chose Subtraction"<<endl;
    }
    
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
    }

  2. #2
    Registered User
    Join Date
    Dec 2010
    Location
    Australia
    Posts
    8
    What are you having trouble with exactly? The logic of the application? Or compiler errors? All you have done is post us your assignment question and your attempted code.

    Also, please don't be afraid to use spacing and indentation. It dramatically increases the readability of the code.

    Thanks.

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Hey Katie I was going to reply the same what LifeInCode has replied. But he was already there before me. But anyway, while you reply to his post, few things which I noticed and you might have to consider

    1. C++ evaluates express from right to left. So the following statment would get the result be stored in answer.
    Code:
    gone + gtwo = answer;
    should have been
    answer = gone + gtwo;
    2. You might as well consider using either if-else if-else statment or switch statment rather the using just if. As you are comparing more then once, after the first match. Thats is if your choice was 2, the control will check for if choice is 1,2,3,4 etc, that when you use the way you've used in your code. But using else if, the control will check if choice is 1 and checks choice is 2. And yes the choice is 2 and the control dosen't bother comparing 3 and 4 as obvious.

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  4. #4
    Registered User Mirage's Avatar
    Join Date
    Dec 2010
    Posts
    6
    If the kid guesses wrong it will just exit the program instead of letting them try again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hi, Quiz C program Assignment updated
    By Eman in forum C Programming
    Replies: 19
    Last Post: 11-22-2009, 04:50 PM
  2. Replies: 2
    Last Post: 04-03-2009, 05:57 PM
  3. Multi-threaded for-loop (test my program)
    By Sang-drax in forum C++ Programming
    Replies: 9
    Last Post: 04-28-2005, 11:07 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM