+ Reply to Thread
Results 1 to 7 of 7

Thread: Help needed making long C program.

  1. #1
    Newbie lio180 is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    3

    Help needed making long C program.

    Hi all,
    I have this project in me c programming course.
    and i really don't know how to do it, so please i need your help with any suggestion or codes.


    Project Title: Arithmetic Test Tool
    Write a c program to test students’ knowledge of mental arithmetic.
    Your program should keep track of a list of students who took a test with their scores in a file. The different types of operations tested by your system are as follows:
    Multiplication: is limited to integer numbers only with 2 levels of difficulty.
    1- single digit with single digit (score of 1 for correct answer.)
    2- double digit with single digit (score of 2 for correct answer)

    Division: division is limited to integer division. Thus the program will ask for result of division and remainder. 2 levels of difficulty.
    1- double digit numerator (score of 2 for correct answer: 1 for correct division result and 1 for correct remainder)
    2- 3 digit number for numerator (score of 3 for correct answer: 2 for correct division result and 1 for correct remainder)
    For both cases the denominator is between 2 and 9.

    Integer addition and subtraction: two levels of difficulty.
    1- 2 digit with 2 digit numbers ( 1 for correct answer)
    2- 3 digit with 3 digit numbers (2 for correct answer)

    Floating point addition and subtraction: two levels of difficulty.
    1- 1 digit before decimal point and one digit after decimal point. (2 for correct answer)
    2- 1 digit before decimal point with 2 digits after decimal point. (3 for correct answer)
    At the beginning your program will display a menu with choices:
    1- List the names of those who took the test with their scores arranged in increasing or decreasing order.
    2- List the names in alphabetical order.
    3- start the test.
    If the user chooses to start the test, then the program will ask for his name and if he has already taken the test; the program will display his previous score.
    The program gives 10 questions chosen randomly from all cited categories. The questions are displayed one by one. Once the user answers one question the program check if it is correct or not and gives him the score for that question. If the answer is wrong, the program displays the right answer. After that it will display the next question and so on. Once the 10 questions are answered, the program will find the new score. If it is higher than the old one, it will delete the old and saves the new one with the student name. If not it will keep the old score.
    The type of the operation and the numbers used in that operation are selected randomly.

    Note: The function rand() will return a pseudo random number from 0 to RAND_MAX which is the maximum value in the int type. In order to limit your number from 0 to n, make the returned value % (n+1). By using rand() only, your program will generate the same sequence during each execution. To avoid this problem insert the following statement at the beginning of your main function. srand(time(NULL));
    For real values generate random integers, then divide it by 10 to get a number with 1 digit after decimal point, or divide it by 100 to get 2 digits after decimal point.
    You need to insert 2 include statements <stdlib.h> and <time.h>.


    plz help me out with it...

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    37
    Posts
    12,912
    Blog Entries
    57

    Re: Help needed making long C program.

    Do you know how to generate the random numbers you will need? Where, exactly, are you stuck?
    CodeCall Blog | CodeCall Wiki
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  3. #3
    Learning Programmer hodge-podge is an unknown quantity at this point
    Join Date
    Jun 2009
    Location
    New Hampshire.
    Posts
    47

    Re: Help needed making long C program.

    Quote Originally Posted by lio180 View Post
    Hi all,
    I have this project in me c programming course.
    and i really don't know how to do it, so please i need your help with any suggestion or codes.


    Project Title: Arithmetic Test Tool
    Write a c program to test students’ knowledge of mental arithmetic.
    Your program should keep track of a list of students who took a test with their scores in a file. The different types of operations tested by your system are as follows:
    Multiplication: is limited to integer numbers only with 2 levels of difficulty.
    1- single digit with single digit (score of 1 for correct answer.)
    2- double digit with single digit (score of 2 for correct answer)

    Division: division is limited to integer division. Thus the program will ask for result of division and remainder. 2 levels of difficulty.
    1- double digit numerator (score of 2 for correct answer: 1 for correct division result and 1 for correct remainder)
    2- 3 digit number for numerator (score of 3 for correct answer: 2 for correct division result and 1 for correct remainder)
    For both cases the denominator is between 2 and 9.

    Integer addition and subtraction: two levels of difficulty.
    1- 2 digit with 2 digit numbers ( 1 for correct answer)
    2- 3 digit with 3 digit numbers (2 for correct answer)

    Floating point addition and subtraction: two levels of difficulty.
    1- 1 digit before decimal point and one digit after decimal point. (2 for correct answer)
    2- 1 digit before decimal point with 2 digits after decimal point. (3 for correct answer)
    At the beginning your program will display a menu with choices:
    1- List the names of those who took the test with their scores arranged in increasing or decreasing order.
    2- List the names in alphabetical order.
    3- start the test.
    If the user chooses to start the test, then the program will ask for his name and if he has already taken the test; the program will display his previous score.
    The program gives 10 questions chosen randomly from all cited categories. The questions are displayed one by one. Once the user answers one question the program check if it is correct or not and gives him the score for that question. If the answer is wrong, the program displays the right answer. After that it will display the next question and so on. Once the 10 questions are answered, the program will find the new score. If it is higher than the old one, it will delete the old and saves the new one with the student name. If not it will keep the old score.
    The type of the operation and the numbers used in that operation are selected randomly.

    Note: The function rand() will return a pseudo random number from 0 to RAND_MAX which is the maximum value in the int type. In order to limit your number from 0 to n, make the returned value % (n+1). By using rand() only, your program will generate the same sequence during each execution. To avoid this problem insert the following statement at the beginning of your main function. srand(time(NULL));
    For real values generate random integers, then divide it by 10 to get a number with 1 digit after decimal point, or divide it by 100 to get 2 digits after decimal point.
    You need to insert 2 include statements <stdlib.h> and <time.h>.


    plz help me out with it...
    I could be wrong, but.... Wouldn't you write various functions for each game play mode. So you would write a function for each difficulty of addition...Something similar to this...

    Code:
        srand(time(NULL));
        var1 = rand() % 99;
        var2 = rand() % 99;
        answer=var1+var2;
        cout<<var1<<" + "<<var2<<" = ";
        cin>> inp;
        if (answer!=inp){
            cout<<"Wrong Answer";
        } else{
            cout<<"correct";
            arithscore = arithscore + 1;
        }
    }
    As for the menu you would just use switch.

    And for incorporating each mode into a single test you could assign each function to a number so....

    Code:
        
    for(i=0; i<10; i++){
            srand (time(NULL))
            kah = rand() % 10;
            if (kah = 1){
                addition();
            }
            if (kah = 2){
                multiply ();
            }
            etc...
    That should work... I'm sure someone could tell you a more effective way to do it though..

  4. #4
    Newbie lio180 is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    3

    Re: Help needed making long C program.

    Quote Originally Posted by WingedPanther View Post
    Do you know how to generate the random numbers you will need? Where, exactly, are you stuck?
    not exactly because i missed the lecture when the teacher explain it.


    hodge-podge the functions really worked but i have now new problem with this code. no 1 and 2. also how can i change the score if he got more than the previous.

    At the beginning your program will display a menu with choices:
    1- List the names of those who took the test with their scores arranged in increasing or decreasing order.
    2- List the names in alphabetical order.
    3- start the test.
    If the user chooses to start the test, then the program will ask for his name and if he has already taken the test; the program will display his previous score.
    The program gives 10 questions chosen randomly from all cited categories. The questions are displayed one by one. Once the user answers one question the program check if it is correct or not and gives him the score for that question. If the answer is wrong, the program displays the right answer. After that it will display the next question and so on. Once the 10 questions are answered, the program will find the new score. If it is higher than the old one, it will delete the old and saves the new one with the student name. If not it will keep the old score.

    thank you all

  5. #5
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    37
    Posts
    12,912
    Blog Entries
    57

    Re: Help needed making long C program.

    That sounds like you'll need to store the scores in a file someplace.
    CodeCall Blog | CodeCall Wiki
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #6
    Learning Programmer hodge-podge is an unknown quantity at this point
    Join Date
    Jun 2009
    Location
    New Hampshire.
    Posts
    47

    Re: Help needed making long C program.

    Quote Originally Posted by lio180 View Post
    not exactly because i missed the lecture when the teacher explain it.


    hodge-podge the functions really worked but i have now new problem with this code. no 1 and 2. also how can i change the score if he got more than the previous.

    At the beginning your program will display a menu with choices:
    1- List the names of those who took the test with their scores arranged in increasing or decreasing order.
    2- List the names in alphabetical order.
    3- start the test.
    If the user chooses to start the test, then the program will ask for his name and if he has already taken the test; the program will display his previous score.
    The program gives 10 questions chosen randomly from all cited categories. The questions are displayed one by one. Once the user answers one question the program check if it is correct or not and gives him the score for that question. If the answer is wrong, the program displays the right answer. After that it will display the next question and so on. Once the 10 questions are answered, the program will find the new score. If it is higher than the old one, it will delete the old and saves the new one with the student name. If not it will keep the old score.

    thank you all
    You would have it create a file somewheres and at the start of the program I will read the file, get the score and store it as the score variable. As the test goes on the score will increase, and at the end it will write the new variable to the file. You could do the same with the list of users etc.

  7. #7
    Newbie lio180 is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    3

    Re: Help needed making long C program.

    sorry for being late, but the univ internet was down yesterday.

    i created the file with questions but i had problems in first step which is sorting the names by alphabetical order and the scores in increasing or decreasing order.

    At the beginning your program will display a menu with choices:
    1- List the names of those who took the test with their scores arranged in increasing or decreasing order.
    2- List the names in alphabetical order.


    i made the name as a string and the score is type int.

    thank you again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 8
    Last Post: 12-16-2009, 11:53 AM
  2. Tutorial: Starting C# with C# 2008 Express Edition
    By Jordan in forum CSharp Tutorials
    Replies: 20
    Last Post: 07-27-2009, 01:45 AM
  3. Debugging a C++/C File with GDB Debugger
    By awesome001 in forum C and C++
    Replies: 2
    Last Post: 01-01-2009, 05:07 PM
  4. need help C++ program
    By statquos in forum C and C++
    Replies: 3
    Last Post: 06-12-2008, 09:23 AM
  5. SecurityAudit
    By vinay in forum Visual Basic Programming
    Replies: 27
    Last Post: 01-07-2008, 10:14 AM