Home Answers Viewqa Java-Beginners Tell us the logic of diceroller

 
 


Manasa
Tell us the logic of diceroller
1 Answer(s)      a year and 11 months ago
Posted in : Java Beginners

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 Pages:
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
please tell me
please tell me   <tr>..." /></td> </tr> </logic:iterate> </logic:notEmpty> </logic:present> how can i
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
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
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
deploy jsp using web logic - Java Beginners
deploy jsp using web logic  Hi all, I am new in Web logic server please tell me what is the steps of writing deployee the jsp using web logic. and steps also arrange the folder its urgent
Can anybody tell me how to resolve this issue?
Can anybody tell me how to resolve this issue?  java.lang.Exception: Exception : java.lang.Exception: Generic Errors = java.util.MissingResourceException: Can't find bundle for base name Connection, locale en_US
Abut Deploying and Developing Web-Logic in JDK1.5 version to run the EJB
Abut Deploying and Developing Web-Logic in JDK1.5 version to run the EJB  Hello What is the path setting for the Web-Logic and how to deploy and run the Web-Logic in JDK1.5 version. And can we have Tomcat installed
Logic and desgin
Logic and desgin  How would this be put in visual logic symbol
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
please tell anybody how can i set a value in hiperlink for edit n delete link
please tell anybody how can i set a value in hiperlink for edit n delete link  <logic:present name="allRecords"> <logic:notEmpty name="allRecords"> <logic:iterate id="user" name
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
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
Business logic vs Presentation logic - JSP-Servlet
Business logic vs Presentation logic  what is the difference between Business logic and Presentation logic
What is programming logic ?
What is programming logic ?  What is programming logic
please tell me
please tell me  why we are using http protocol in servlets
Tell me - Struts
Directory Structure for Struts  Tell me the Directory Structure for Struts
WEB LOGIC - JSP-Servlet
WEB LOGIC project  I want the procedure to run a project in we logic server
the business logic is executed.
the business logic is executed.  In which method of Action class the business logic is executed
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
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
please tell me
please tell me  which cmd we use to clear the screen in sql prompt
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
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 the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
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
please tell me
please tell me  class Person{ string name; int age; void talk(){ System.out.println("my name is"+name); System.out.println("my..., i got this error....... please tell me the resolution
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
Latitude and Longitude of Virgin Islands (US)
Latitude and Longitude of Virgin Islands (US)  Hi, What is the Latitude and Longitude on Virgin Islands (US)? Thanks   Hi, Latitude of Virgin Islands (US) is:18° 20' N and Longitude of Virgin Islands (US) is: 64° 50
please tell me
please tell me  import java.io.*; class SString{ public static void main(String ar[]) throws IOException{ BufferedReader br = new Bufferedreader(new... error please tell me the resolution
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
struts logic tags
struts logic tags  what is the use of struts logic tag   The purpose of Struts logic tags is to alter output depending on the given...://www.roseindia.net/struts/struts-logictags/logic-tags-introduction.shtml http
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

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.