Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


langat
math radom
1 Answer(s)      6 years and 7 months 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


Advertisement
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!");
}
}
}
}



Related Tutorials/Questions & Answers:
java Math class
java Math class  Why are the methods of the Math class static
Java math class
Java math class  Can you instantiate the Math class
Advertisements
Java math class
Java math class  Why can?t I say just abs() or sin() instead of Math.abs() and Math.sin
Math Constants and Functions using JavaScript
Math Constants and Functions using JavaScript  What's Math Constants and Functions using JavaScript
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
Evaluating a math expression given in string form
Evaluating a math expression given in string form  Evaluating a math expression given in string form
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
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
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
Introduction To Math Class In Java
Introduction To Math Class In Java In this tutorial we will read about.... Math class is created inside the java.lang package and the classes created inside... the application. Class Declaration public final class Math extends Object Constant
Mysql Math Function
Mysql Math Function       Math Function involved in Mysql when we perform some operation... 'Mysql Math Function'. The below Syntax help you to perform Math Function : ABS(X
Mysql Math Function
Mysql Math Function       Math Function involved in Mysql when we perform some operation... an example from 'Mysql Math Function'.The below Syntax help you to perform Math
JavaScript exp method
by using the Math object reference. In Math object we have some very useful.... The exp() method of Math object returns the value of ex , where "e"
TeXlipse
closing of acrobat on Windows, smartkeys, reference hovers and math commands... also. Some of the new things: more command completions, more math modes, syntax
XML Interviews Question page9
, if the document type you use provides for math, and your users' browsers... other DTDs, such as ISO 12083 Math, or OpenMath, or one of your own making. Browsers which display math embedded in SGML existed for many years (eg DynaText
Randomizer
by using the random() method of the Math class and change them into different... by the randomFloat() method by using the round() method of the Math class. Now we
Give difference between LinkedList and ArrayList - Java Beginners
, Differences: ArrayList provides fast radom access while LinkedList does
Change a file timestamp
C:\vinod\Math_package>javac ChangeFileDate.java C:\vinod\Math_package>java ChangeFileDate Change file timestamp example! Enter file name with extension: StrStartWith.shtml Enter last
Intro Java help with Double
Intro Java help with Double  I have to evaluate a math expression using double in Java. I can input the code fine for the expression, but I don't know how to view the answer that it gives me. help
Question in Java ??
Question in Java ??   Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number squrfoot
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
Question in Java ??
Question in Java ??  Welcome every One ,I have Q in Java : Write aprogram that print the falewing table using SQRT method in the Math Class? Number 0 ,2, . . . ,18,20 squrfoot 00000 1.4142 5.2426 5.4721
java - Java Beginners
java  i have to make a programm in java to multiply any number with 100 without using any math operator.  To multiply with 100 no need of mathematical operators. int result=Integer.parseInt(String.valueOf(num)+"00
PHP list array
,'jack', 'math');      list($roll, $name, $subject... is math
Random in jsp
. random() is a method of Math class which extends java.lang package. The Math... we are going to make a use of random() method of the Math class. We are using
For Loop/PHP
For Loop/PHP  Write a class called math. It is to have one property called num. It also has one method called factorial. This method is to start...;Here is a java example that finds the factorial of a number. public class math
Apollo for Eclipse
++ templates for parallelism, math processing, and multimedia libraries...) and Intel® Math Kernel Library (Intel® MKL). While these libraries
C++ Compiler for Linux
++ templates for parallelism, math processing, and multimedia libraries...) and Intel® Math Kernel Library (Intel® MKL). While these libraries are available
java program
of a circle and calculate area? formula=pirr (use math class) sample output
Lang and Util Base Libraries
, a basic math class etc. It also provide wrapper class. Math Math functionality includes floating point libraries and arbitrary-precision math. Monitoring
Advertisements
 

 

 

DMCA.com