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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Manasa
Tell us the logic of diceroller
1 Answer(s)      3 years and 5 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????


Advertisement
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
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
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
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
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
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
please tell me
please tell me   <tr>..." /></td> </tr> </logic:iterate> </logic:notEmpty> </logic:present> how can i
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
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
Business logic vs Presentation logic - JSP-Servlet
Business logic vs Presentation logic  what is the difference between Business logic and Presentation logic
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
What is programming logic ?
What is programming logic ?  What is programming logic
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  why we are using http protocol in servlets
Tell me - Struts
Directory Structure for Struts  Tell me the Directory Structure for Struts
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
what is the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
please tell me
please tell me  which cmd we use to clear the screen in sql prompt
please tell me
please tell me  why we use public static main(String ar){} in java instead of main
Tell me - Struts
Directory Structure with example program Execution  Tell me the Directory Structure with example program Execution
Tell me - Struts
Struts tutorial to learn from beginning   Tell me, how can i learn the struts from beginning
Pls anyboby tell me...
Pls anyboby tell me...  which book easy to learn spring
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
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
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
Advertisements
 

 

 

DMCA.com