d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > School Question, Newbie Coder Needs Help > C++
Add Reply New Topic New Poll
Member
Posts: 271
Joined: Feb 19 2010
Gold: 130.00
Oct 11 2012 07:27pm
Hi there,
Was curious if any coder could help me out with this :)

______________

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. (10 points)

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>


Member
Posts: 20,702
Joined: Oct 7 2006
Gold: 9,662.00
Oct 31 2012 09:26pm
E: nvm

This post was edited by bullet886 on Oct 31 2012 09:27pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 1 2012 04:30pm
What do you need help with? Post your code or pseudocode.
Member
Posts: 2,948
Joined: Feb 12 2008
Gold: 290.00
Nov 4 2012 02:14am
pretty simple here.. here's a little example I whipped up in C#


while (true)
{
Random rand = new Random();
int x = rand.Next(0, 11);
int y = rand.Next(0, 11);

Console.WriteLine("How much is " + x + " times " + y + "?");
int response = int.Parse(Console.ReadLine());

while (response != (x * y))
{
Console.WriteLine("Sorry, that is incorrect, please try again");
response = int.Parse(Console.ReadLine());
}

Console.WriteLine("Correct!");
}
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll