Do you know how to generate the random numbers you will need? Where, exactly, are you stuck?
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...![]()
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
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...
As for the menu you would just use switch.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; } }
And for incorporating each mode into a single test you could assign each function to a number so....
That should work... I'm sure someone could tell you a more effective way to do it though..Code:for(i=0; i<10; i++){ srand (time(NULL)) kah = rand() % 10; if (kah = 1){ addition(); } if (kah = 2){ multiply (); } etc...
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
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
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.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)