Tell us the logic of diceroller

Tell us the logic of diceroller

import java.io.*; import javax.servlet.*; import javax.servlet.http.*;

public class DiceRollerServlet extends HttpServlet{ protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{ PrintWriter pw = response.getWriter(); String dice1 = Integer.toString((int)(Math.random()*6)+1); String dice2 = Integer.toString((int)(Math.random()*6)+1); pw.println(""); pw.println("dice roller
"); pw.println("dice1 value is " + dice1 + " and
dice2 value is " +dice2); } }

dice1 =3 dice2 =2

How is the logic executed????

View Answers

June 15, 2011 at 12:10 PM

The (Math.random()*6)+1 returns the random number between 1 and 6 only. so it display 3 for the first dice and 2 for another one.

For more information, visit the following link:

http://www.roseindia.net/servlets/DiceRoller.shtml









Related Tutorials/Questions & Answers:
Tell us the logic of diceroller
Tell us the logic of diceroller  import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class DiceRollerServlet extends... is " +dice2); } } dice1 =3 dice2 =2 How is the logic executed????   
With reference to the question " TELL US THE LOGIC OF DICEROLLER"???
With reference to the question " TELL US THE LOGIC OF DICEROLLER"???  Tell us the logic of diceroller 1 Answer(s) 18 minutes and 38 seconds ago Posted in : Java Beginners As told ""The (Math.random()*6)+1 returns the random
Advertisements
ModuleNotFoundError: No module named 'diceroller'
ModuleNotFoundError: No module named 'diceroller'  Hi, My Python... 'diceroller' How to remove the ModuleNotFoundError: No module named 'diceroller' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'diceroller'
ModuleNotFoundError: No module named 'diceroller'  Hi, My Python... 'diceroller' How to remove the ModuleNotFoundError: No module named 'diceroller' error? Thanks   Hi, In your python environment you
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
Logic and desgin
Logic and desgin  How would this be put in visual logic symbol
please tell me
please tell me   <tr>..." /></td> </tr> </logic:iterate> </logic:notEmpty> </logic:present> how can i
Logic Building
Logic Building  I wanted to devlop my logic ? How can i do so ? Can i start with java or i need to do c++ before
About Web-Logic
the Web-Logic with Tomcat 5.0 version in Console. Somebody has suggested to see the webpage (they had given the link).But when i installed the Web-Logic i culdn't find META-INF directory . So Kindly tell me where Will be the META-INF
Logic Iterate.
Logic Iterate.  I have one doubt about logic:iterate. I use text feild inside of logic:iterate , there is possible will generate N no of rows (text feild) inside of iterate. my doubt is how to get the Paritcular rows text
Logic Iterate.
Logic Iterate.  logic iterate Struts I have one doubt about logic:iterate. I use text field inside of logic:iterate , there is possible... the Particular rows text value. for example: print("<logic:iterate id="xid
ModuleNotFoundError: No module named 'us'
ModuleNotFoundError: No module named 'us'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'us' How to remove the ModuleNotFoundError: No module named 'us' error
ModuleNotFoundError: No module named 'us'
ModuleNotFoundError: No module named 'us'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'us' How to remove the ModuleNotFoundError: No module named 'us' error
ModuleNotFoundError: No module named 'us'
ModuleNotFoundError: No module named 'us'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'us' How to remove the ModuleNotFoundError: No module named 'us' error
ModuleNotFoundError: No module named 'tell'
ModuleNotFoundError: No module named 'tell'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tell' How to remove the ModuleNotFoundError: No module named 'tell' error
Business logic vs Presentation logic - JSP-Servlet
Business logic vs Presentation logic  what is the difference between Business logic and Presentation logic
Tell me - Struts
Directory Structure for Struts  Tell me the Directory Structure for Struts
please tell me
please tell me  why we are using http protocol in servlets
data science master us
master us Try to provide me good examples or tutorials links so that I can learn the topic "data science master us". Also tell me which is the good
master of data science us
of data science us Try to provide me good examples or tutorials links so that I can learn the topic "master of data science us". Also tell me which
please tell me
please tell me  i have created one table,when i close and again login, table name will be there, but its content not displayed, showing as no rows selected, please tell me the reason
Struts logic iterate
Struts logic iterate  This is my jsp page in which i used 3 logic...; <%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>...; <body> <h1> Search </h1> <logic:iterate name
please tell me
please tell me  which cmd we use to clear the screen in sql prompt
Pls anyboby tell me...
Pls anyboby tell me...  which book easy to learn spring
Tell me - Struts
Struts tutorial to learn from beginning   Tell me, how can i learn the struts from beginning
Tell me - Struts
Directory Structure with example program Execution  Tell me the Directory Structure with example program Execution
please tell me
please tell me  why we use public static main(String ar){} in java instead of main
Logic and Degin
Logic and Degin  Need help in writing a pseudocode for this can so please help me with this just need to get started. In this lab, you are going to extend the Fireworks Checkout Stand application in Week 6. This week, we
Tell me - Java Beginners
Tell me   how to create a valid.js file please tell me and give the write code Thanks  Hi friend, Please give details for requirement of this "valid.js" file. For read more information http
please tell me
please tell me  select * from emp order by 5 desc; in the above what is the meaning of 5, and what its functionality
What is programming logic ?
What is programming logic ?  What is programming logic
please tell me
please tell me  Actually i am working on a Project tiitle is JavaMail System, 1)How to configure java mail API and a Demo Program for Sending mail and Receiving using JSP and Servlet
Logic and Design
Logic and Design  Please help me with this Write a program that prompts and accepts a number between 1 and 12. After getting the input, display the number with the appropriate month. (example: This is the 1st month¦January
logic-iterate
logic-iterate  in my code i am using for-each loop for displaying data i want use tag to display data how to use plase help me <%@ page import="java.sql.*" %> <%String[] id = (String[])session.getAttribute("ids
please tell me
please tell me  what are the topics in core and advaced java....   Hi Friend, Please visit the following links: http://www.roseindia.net/ http://www.roseindia.net/java/ Thanks   Hi Friend, Please visit
tell me coding for this
tell me coding for this  Write an application that displays the integer equivalents of the following character...A   Java get Integer value of Character class GetIntValueOfCharacter { public static void main
please tell me
please tell me  class Person{ int age; String name; void Person1(String g,int a){ name=g; age=a; } Person(String s,int i){ name=s; age=i; } void..., but its compiled and run successfully, please tell me the reason
please tell me
please tell me  import java.lang.Thread; class Current{ public static void main(String ar[]){ Thread t = Thread.CurrentThread(); System.out.println...(); ^ 1 error tell me the resolution please....   import
please tell me
please tell me  class Person{ string name; int age; void talk(){ System.out.println("my name is"+name); System.out.println...: '}' expected ^ 2 errors, i got this error....... please tell me the resolution
please tell me
please tell me  import java.io.*; class SString{ public static void main(String ar[]) throws IOException{ BufferedReader br = new Bufferedreader...)); ^ 1 error please tell me the resolution of this   Hi
please tell me
please tell me  class Sample{ private double num1,num2; void sample(double x,double y){ num1=x; num2=y; } void Sum(){ double result=num1+num2...(10.6,20.0); ^ 1 error, please tell me the resolution for this...   
please tell me
please tell me  class Person{ int age; String name; void talk(){ System.out.println("my name is:"+name); System.out.println("my age is:"+age); } } class Hash{ public static void main(String ar[]){ Person raju=new Person
plz tell me
plz tell me  how to get no. of times the 'button' is pressed   Here is a java swing code that counts the number of times the button clicked. import javax.swing.*; import java.awt.event.*; public class
please tell me
please tell me  class Reserve extends Thread{ int available=1; int wanted; Reserve(int i){ wanted = i; } public static void...; ^ please tell me the resolution   class Reserve
please tell me
please tell me  class Producer extends Thread { StringBuffer sb; boolean dataprodover = false; Producer(){ sb = new StringBuffer(); } public void... got error as Inner class connot have static declarations pls tell me
please tell me
please tell me  Blockquote Blockquote> BlockquoteBlockquote how to get images from ms access databases to jsp pagesBlockquote   Jsp get image from ms access database Create a table named user(id,name,address,image
the business logic is executed.
the business logic is executed.  In which method of Action class the business logic is executed
WEB LOGIC - JSP-Servlet
WEB LOGIC project  I want the procedure to run a project in we logic server
please tell me
please tell me  what is the source code if user give wrong user name password the explorer will show incorrect username password   <% String vlname=request.getParameter("lname"); String vpwd=request.getParameter

Ads