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

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 Pages:
Java math class
Java math class  Can you instantiate the Math class
java Math class
java Math class  Why are the methods of the Math class static
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
Summary: Math Class
Java Summary: Math Class In this section we will study about the Match class of Java API. Some basic math functions can be found in the Math class...; double ar; // angle in radians. x is any of int, long, float, or double. Math
Summary: Math and java.util.Random Classes
Java Summary: Math and java.util.Random Classes In this section we will discuss Math and java.util.Random classes. Both these classes can be used for generating the random numbers. Some basic math functions can be found in the Math
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
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... from 'Mysql Math Function'.The below Syntax help you to perform Math Function : ABS
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"
Methods - OOP
. A good example of a static methods in Java is the Math or Character... in the Math class. Cosine takes only one (primitive) parameter, and it doesn't work
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
Count lines of a particular file
C:\vinod\Math_package>javac NumberOfLine.java C:\vinod\Math_package>java NumberOfLine Getting line number of a paritcular file example! Please enter file name with extension: AddTwoBigNumbers.shtml
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
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
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
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
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
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
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
Programming - max3() method
. No Math methods You may not use Math.max() or Math.min() Method
Fill in the blanks.
as ___. 4 ___method of Math class returns the largest integer number less than
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
Java Compilation - Java Beginners
Java Compilation  Dear Sir, Could you please send me the program code for the following java program? Q:Create a classname Math with its required... Math { public static int add(int a,int b){ return a+b; } public static
String length example
:\vinod\Math_package>javac StringLength.java C:\vinod\Math
Trim String Example
this example. Output of program: C:\vinod\Math_package>javac StringTrim.java C:\vinod\Math_package>java StringTrim String trim
java programming problem - Java Beginners
get the solution.(for BSc Math Hon's Student
Java - RMI
Java  Write and deploy a simple, Java RMI-based Client/Server application, in which the (multithreaded) Server serves requests of remote Java Clients for mathematical operations. This is a simple Math Service, which we'll refer
Java - Java Beginners
Java  How to make a multiple choice quiz in java, 1- Quiz program that answers questions about Math, Science and Arts. 2- Student selects the topic, the program presents a series of questions. 3- Student should answer
java
java  write a complete java application to prompt the user for the radius of a sphere,and call method sphereVolume to calculate and display the volume of the sphere.use the Math.pow(radius)method and Math.PI constant of Math
Compare string example
. Output of program: Both are equals: C:\vinod\Math_package>javac CompString.java C:\vinod\Math_package>java CompString... Both are not equals: C:\vinod\Math_package>java CompString
math.radom - Java Beginners
math radom  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
java - Java Beginners
java  i have to make a programm in java to multiply any number with 100 without using any math operator.I hav got this answer. but i hav to make it without using +,*,/,- etc. here + is used in this. Answers To multiply
Simple Java Calculator - Java Beginners
Simple Java Calculator  Write a Java program to create simple Calculator for 4 basic Math operations, Addition, Subtraction, Multiplication and Division. The calculator should simulate the look of handheld calculator containing
Java Project - Java Beginners
Java Project   Write a Java program to create simple Calculator for 4 basic Math operations, Addition, Subtraction, Multiplication and Division. The calculator should simulate the look of handheld calculator containing
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
i cNT GET ANSWER FOR THIS QUESTION
. (Hint: Use the method pow or sqrt from the class Math to calculate the square

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.