Thread: Java Help
View Single Post
  #2 (permalink)  
Old 04-01-2008, 03:20 AM
Bluefox815 Bluefox815 is offline
Member
 
Join Date: Feb 2008
Location: Oregon, USA
Posts: 24
Bluefox815 is on a distinguished road
Send a message via MSN to Bluefox815
First off, a few pointers (see comments)

Code:
using std::cin; using std::endl; // #include changes to import, there are no namespaces void multiplication(); // this isn't needed no matter where your functions (or methods, as they're called in Java) are placed /* main changes to public static void main(String[] args) {} // notice that return type is void */ int main() { multiplication(); return 0; } void multiplication() { int x; int y; int response = 0; while ( response != -1 ) { x = rand() % 10; // I'm not sure what you tried to do here y = rand() % 10; // but these two would change cout << " How much is " << x << " times " << y << " ( -1 to End ) ? : "; // cout changes to System.out.print(stuffToWrite) and << changes to a plus sign (+) cin >> response; // cin is trickier, too much to explain 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
I didn't know how new you were, so I just converted everything I know.

I would convert the whole program to Java but I can't see what you are doing with "rand() % 10", if you tell me what rand() does then I should be able to convert it for you, unless you think you have it down.
Reply With Quote