math radom

Ads

 
 

Share on Google+Share on Google+

langat
math radom
1 Answer(s)      9 years ago
Posted in : Java Beginners

Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use Math.random to produce two positive one-digit integers. The program should

Ads
View Answers

April 11, 2008 at 7:10 PM


Hi friend,

import java.util.*;
import java.util.Scanner;

public class MultiplicationRandom{
public static void main(String[] args){
int num1 = 0;
int num2 = 0;
int num;
int user;
num1 = (int)(Math.random() * 9+1);
num2 = (int)(Math.random() * 9+1);
num = num1 * num2;
while(true){
// get answer from user
Scanner input = new Scanner(System.in);
System.out.println("How much is " + num1 + " TIMES " + num2 + "?");
user = input.nextInt();
if(user!= num){
System.out.println( "No. Please try again.");
}
else{
System.out.printf( "Very Good!");
}
}
}
}


Ads









Related Tutorials/Questions & Answers:
Version of commons-math>commons-math dependency
List of Version of commons-math>commons-math dependency
Java math class
Java math class  Can you instantiate the Math class
Advertisements
java Math class
java Math class  Why are the methods of the Math class static
Version of com.techshroom>Math dependency
List of Version of com.techshroom>Math dependency
Java math class
Java math class  Why can?t I say just abs() or sin() instead of Math.abs() and Math.sin
Artifacts of commons-math
List of Artifacts of commons-math maven depenency
Math Constants and Functions using JavaScript
Math Constants and Functions using JavaScript  What's Math Constants and Functions using JavaScript
Maven Dependency commons-math >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-math >> commons-math version1.0 in your project
Maven Dependency commons-math >> 1.1
You should include the dependency code given in this page to add Maven Dependency of commons-math >> commons-math version1.1 in your project
Maven Dependency commons-math >> 20040118.003354
You should include the dependency code given in this page to add Maven Dependency of commons-math >> commons-math version20040118.003354 in your project
Maven Dependency commons-math >> 20040118.003950
You should include the dependency code given in this page to add Maven Dependency of commons-math >> commons-math version20040118.003950 in your project
Maven Dependency commons-math >> 20040218.045431
You should include the dependency code given in this page to add Maven Dependency of commons-math >> commons-math version20040218.045431 in your project
Version of com.cjmalloy>gwt-math dependency
List of Version of com.cjmalloy>gwt-math dependency
Version of com.enterprisemath>em-math dependency
List of Version of com.enterprisemath>em-math dependency
Version of com.accelad>nilgiri-math dependency
List of Version of com.accelad>nilgiri-math dependency
Version of com.flowpowered>flow-math dependency
List of Version of com.flowpowered>flow-math dependency
Math Program - Java Beginners
Math Program  The greatest common divisor of two integers 16 and 24 is 8. Develop the algorithm for finding the greatest common divisor of two numbers. Write a program that prompts the user to enter two integers and calculates
which part of the cpu does math calculations
which part of the cpu does math calculations  which part of the cpu does math calculations logical calculation
Evaluating a math expression given in string form
Evaluating a math expression given in string form  Evaluating a math expression given in string form
Can you instantiate the Math class? - Java Beginners
Can you instantiate the Math class?   Hi, Can you create object of Math class? Thanks   Hi, All the methods in Math class is static. The constructor is not public in the Math class. So, we can't create
Maven Dependency Math >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.techshroom >> Math version1.0.0 in your project
Version of com.accelad>nilgiri-math-evaluator dependency
List of Version of com.accelad>nilgiri-math-evaluator dependency
Java - Math class in Java
Java - Math class in Java       In this example you will learn about Math class. This example explains how you can use functions provided by the Math class like E, PI, round, abs
Maven Dependency nilgiri-math >> 1.10
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.10 in your project
Maven Dependency nilgiri-math >> 1.11
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.11 in your project
Maven Dependency nilgiri-math >> 1.12
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.12 in your project
Maven Dependency nilgiri-math >> 1.13
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.13 in your project
Maven Dependency nilgiri-math >> 1.14
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.14 in your project
Maven Dependency nilgiri-math >> 1.15
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.15 in your project
Maven Dependency nilgiri-math >> 1.6
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.6 in your project
Maven Dependency nilgiri-math >> 1.7
You should include the dependency code given in this page to add Maven Dependency of com.accelad >> nilgiri-math version1.7 in your project