d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Homework Assignment Help(low Level Code) > C++
12Next
Add Reply New Topic New Poll
Member
Posts: 271
Joined: Feb 19 2010
Gold: 130.00
Oct 11 2012 07:39pm
1. (Computer-Assisted Instruction) The use of computers in education is referred to as
computer-assisted instruction (CAI). Write a program that will help an elementary school
student learn multiplication. Use the rand function to produce two positive one-digit
integers. The program should then prompt the user with a question, such as
How much is 3 times 9?


The student then inputs the answer. Next, the program checks the student’s answer. If
it’s correct, display the message "Very good!" and ask another multiplication question. If
the answer is wrong, display the message "No. Please try again." and let the student try
the same question repeatedly until the student finally gets it right.

Hint: use the following functions in your program:
x = rand() % 10; // generate 1-digit random number
y = rand() % 10; // generate another 1-digit random number

Also, use the following libraries as headers
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

Due tonight, and confused. Any help appreciated.
If you can figure this I could tip here in a bit, can purchase fg if needed
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 11 2012 07:54pm
what are you confused about?

pseudocode without the loop:

num1 = rand % 10
num2 = rand % 10

print "what is $num1 times $num2?"
answer = getResponse()

if answer is not num1 * num2:
print "wrong bitch"
loop

print "good job"


/edit: and dont post in both subforums. once is enough

This post was edited by carteblanche on Oct 11 2012 07:57pm
Member
Posts: 271
Joined: Feb 19 2010
Gold: 130.00
Oct 11 2012 08:06pm
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Member
Posts: 25,911
Joined: Dec 2 2007
Gold: 1.00
Oct 11 2012 08:06pm
post your code, so we can see where you are having problems.
Member
Posts: 271
Joined: Feb 19 2010
Gold: 130.00
Oct 11 2012 08:11pm
Sorry about double post
Code
#include <stdafx.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int _tmain(int argc, _TCHAR* argv[])
{
num1 = rand % 10
   num2 = rand % 10

 printf( "what is $num1 + $num2?" )
  answer = getResponse()

if answer is not num1 * num2:
 printf ("wrong");
loop

printf( "good job" );
return 0;
}


Still failing after this. I am getting showing incorrect input variable?

ps. using MS Visual Studio 2010

This post was edited by jriehle87 on Oct 11 2012 08:12pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 11 2012 08:11pm
this is def not low level programming lol

id do this in asm but it be a waste of time
Member
Posts: 25,911
Joined: Dec 2 2007
Gold: 1.00
Oct 11 2012 08:13pm
you need

srand(time(0));

at the front of your main, only needs to be done one time

and your rand is missing ()
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 11 2012 08:13pm
Quote (jriehle87 @ Oct 11 2012 10:11pm)
Sorry about double post
Code
#include <stdafx.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int _tmain(int argc, _TCHAR* argv[])
{
num1 = rand % 10
   num2 = rand % 10

 printf( "what is $num1 + $num2?" )
  answer = getResponse()

if answer is not num1 * num2:
 printf ("wrong");
loop

printf( "good job" );
return 0;
}


Still failing after this. I am getting showing incorrect input variable?


you have not declared num1 and num2 or answer. that is not the structure for printf.

that getResponce function does not exist

the if statement isnt even syntaxially correct

niether is that loop.

do you even attend class or what?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 11 2012 08:13pm
Quote (jriehle87 @ Oct 11 2012 10:11pm)
Sorry about double post
Code
#include <stdafx.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int _tmain(int argc, _TCHAR* argv[])
{
num1 = rand % 10
   num2 = rand % 10

 printf( "what is $num1 + $num2?" )
  answer = getResponse()

if answer is not num1 * num2:
 printf ("wrong");
loop

printf( "good job" );
return 0;
}


Still failing after this. I am getting showing incorrect input variable?

ps. using MS Visual Studio 2010


dude...did you read the part where i said this was pseudocode? i wrote out the logic for you so you won't be "confused" as you call it.

/edit: making a mental note not to help you anymore.

This post was edited by carteblanche on Oct 11 2012 08:19pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 11 2012 08:14pm
meh to lazy to edit:: how much fg and ill have this done in 5 minutes

This post was edited by AbDuCt on Oct 11 2012 08:14pm
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll