Teen Programmers Unite  


Return to forum top

java progamming problem

Posted by motlaks [send private reply] at March 13, 2002, 11:16:00 AM

Write a program that helps an elementary student learn multiplication.Use two positive one-digit integer which are randomly generated.Your program should then type a question such as;
How much is 6 times 7?

The student then types the answer.Your program checks the student's answer.If it is correct,print"very good!".And then ask another question.If the answer is wrong,print"No.Please try again."And then let the student try the same question repeatedly until the student finally gets it right.

Posted by CodeRed [send private reply] at March 13, 2002, 11:41:54 AM

I JUST WROTE THIS PROGRAM IN ANOTHER THREAD. Plus, it's homework, do it yourself.

Posted by motlaks [send private reply] at March 13, 2002, 12:47:08 PM

that is different.can u help as it wont run!

Posted by taubz [send private reply] at March 13, 2002, 02:18:53 PM

How can we help if you don't ask us a specific question?

- taubz

Posted by CodeRed [send private reply] at March 14, 2002, 01:50:27 PM

How about you gestapo admins stop deleting my posts

Posted by gian [send private reply] at March 14, 2002, 01:59:01 PM

Any particular one that got deleted?

Posted by RedX [send private reply] at March 14, 2002, 02:20:32 PM

Why doesn't it run? Does it compile without errors and warnings? Does it exit with a error message (a scary hex-dump perhaps?)? Or does it just do nothing?

In the first case, check those lines that cause those warnings/errors. Try to correct these, even a warning can kill a program. This is the least difficult one the solve.

The next one can be much trickier to solve. Normaly one would use a debugger to tackle these bugs. But if you don't know how to use one, you can get away with inserting some
cout lines at strategic places in your program. (for example put a 'cout << "name of function";' at the start of every function and a simular at the end)
After you ran this version, you'll know in what function the bug hides. (you could then put in more 'cout' lines but this is a time consuming thing) Then read the code of that functions to find the bug.
This is workable for small programs (low number of functions) but as size grows larger (and it will) it becomes too time consuming to insert and remove all these 'cout' lines.
So learn to use a debugger, it's your best friend.

Third case: check all the selection structures [if, switch, for (for example for (x = 0; x < someVariable; x++) check if someVariable isn't zero)]

If you can't find the problem this way, then put you code online and let us have a look.


You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.