Thread: Java Help
View Single Post
  #1 (permalink)  
Old 04-01-2008, 01:31 AM
Ryano Ryano is offline
Member
 
Join Date: Apr 2008
Posts: 1
Ryano is on a distinguished road
Java Help
I am not sure if I am in the right forum but I am writing a code in Java to produce random multiplication. I wrote it in C++ but I am kinda new to Java. Can anyone help me translate this program that I wrote in c++ to Java.

using std::cin;
using std::endl;

void multiplication();

int main()
{
multiplication();

return 0;
}
void multiplication()
{
int x;
int y;
int response = 0;

while ( response != -1 ) {
x = rand() % 10;
y = rand() % 10;

cout << " How much is " << x << " times " << y
<< " ( -1 to End ) ? : ";
cin >> response;

while ( response != -1 && response != x * y ) {
cout << " No. Please try again: " ;

cin >> response;

} //End While

if ( response != -1)
cout << "Very Good!\n\n";

} //End while

} // End function multiplication
Reply With Quote
Sponsored Links