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



Home Answers Viewqa JSP-Servlet understanding buttons :JSP random no program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


gurpreet singh
understanding buttons :JSP random no program
2 Answer(s)      3 years and 9 months ago
Posted in : JSP-Servlet


I hav java random no generator program but i need to implement it in JSP such that page generates random no between 100 and 200 on loading and on clicking submit button it ives message box or just shows on page "no is less"if it less then 150 else shows "no is greater" please help me to understand buttons .thank you java code for random no generation:

public class TestRandom
{
   public static void main(String args[]){
        Random r = new Random();
        int start = 100, end = 200; //The random number will be between 100 and 200
        for(int i=0;i<10;){ //suppose here 10 numbers ll be generated
            int rand = r.nextInt();
            if(rand>100 && rand<200){
                System.out.println(rand);
                i++;
            }
        }
    }
}

Advertisement
View Answers

March 9, 2011 at 11:22 AM


program to generate 1 random no

public class TestRandom
{
   public static void main(String args[]){
        Random r = new Random();
        int start = 100, end = 200;
        if(rand>100 && rand<200){
                System.out.println(rand);
                i++;
            }
        }
    }
}


March 9, 2011 at 12:17 PM


<html>
<script>
function set(){
 var r = Math.floor(Math.random()*200)+100  
document.getElementById("num").value=r;
}
function check(){
var n=document.getElementById("num").value;
if(n>150){
    alert("Number is greater");
}
else{
    alert("Number is lesser");
}
}
</script>
<body onload="set();">
Enter Number: <input type="text" id="num"><br>
</body>
<input type="button" value="check" onclick="check();">


Related Tutorials/Questions & Answers:
understanding buttons :JSP random no program
understanding buttons :JSP random no program  I hav java random no generator program but i need to implement it in JSP such that page generates random no between 100 and 200 on loading and on clicking submit button it ives
Understanding Hello World Java Program
Understanding Hello World Java Program       Now you are familiar with the Java program. In the last lesson you learned how to compile and run the Java program. Before
Advertisements
random number
random number   Please How do I generate a program that gives me random integer from 115 to 250? Using java.util.random. Thank you very much!  ...[] args){ int min = 115; int max = 250; Random random = new Random
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
random number
random number  Sir could u please send me the code registration form of roseindia.net with image varification
random numbers
random numbers  Hi I need some help with the code for the this program. This program should randomly choose a number between 1 and 1000, and then challenge the user to guess what it is, giving hints ('too high!' or 'too low
random numbers
random numbers  hi.. i am creating a website and on feedback form to authenticate user i want to generate a random number on label.if user types that number correctly in textbox then he is allowed to submit feedback otherwise
MySQL random number
MySQL random number       You may fall in the condition when you want to create random number for your program to process some logic, here is the solution for such condition. You can
random numbers - Java Beginners
random numbers  write a program to accept 50 numbers and display 5... java.util.*; class RandomNumberExample { static Random generator = new Random...(); System.out.println("Random numbers are: "); int random[]=new int[5]; for(int i=0;i
Pick at Random
the entry from the array before selecting another name at random
Random in jsp
Random in jsp          Random numbers are the numbers that are determined entirely by chance. User does not have any control over the working of random numbers
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program that stores the names of four employees in an array of strings. Store the contents of the array in an alphabetical order in a file and display it back on console. Do not use
Random Access File.
Random Access File.  Explain Random Access File
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
using random number
using random number  generate a 10 digit number using random number and display the length of longest increasing series
Random Access File class
Random Access File class  Write a short note on Random Access File class.   Please visit the following link: Java Random Access File
demonstrating understanding of data types
demonstrating understanding of data types  Design and implement a Java program that will gather a userÔ??s first name, middle initial, lastname, age in years, and 3 lucky numbers. The program should output the following based
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to write the details of an employee to a file. Details such as year of joining, department code, employee name and salary should be included. You must use RandomAccessFile
getting random number in java
getting random number in java  getting random number in java Hi everyone, i am trying to get a random number in a particular range. for example random numbers between 1 to 100 in Java. Though i m new to Java, i have tried many
Generate Random Numbers
Generate Random Numbers  hi,,, Please give me answer with example How do you generate random numbers within a given limit with actionscript... This function generate random numbers with in given limit
Random data - Java Beginners
Random data  hi friend, I want to ask how to make random data. i has example word like this : Gaza! Gaza! Palestina merdeka! how to make random like : Azag! Azag! Anitselap akedrem! thank's
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  In a random access file, first write the alphabets a,b, c, d till z. Read the file in reverse order and print it on screen
generate random numbers and display the largest
generate random numbers and display the largest  Hi, I am using... it. Write a method to find the largest value in an array. Write a program that takes creates an array and fills it with random ints, prints the contents
using random number
using random number  generate 10 number and display the length of longest incresing series
using random number
using random number  generate 10 digit number and display the length of longest incresing swries
How do I generate random number?
How do I generate random number?  In my Java program there is a requirement of generating random numbers between two given numbers. How do I write code for generating the random number? Thanks   Hi
Generating Random Number
then program will generate any random number for your.  Methods and APIs... to the random number generator. Here is the code of the program... Generating Random Number     
Generate random numbers in Java
Generate random numbers in Java - How to use the java.util.Random class to generate desired random number in Java program? In this tutorial I will teach you... or a set of random numbers in your program. We are using the java.util.Random
Random Creation of password
Random Creation of password  Dear Sir I have created a form with some... to be encrypted and then send to the database.....I am using jsp as my front end and java... to generate a random password and insert into database... Please help me out
Advertisements
 

 

 

DMCA.com