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



Home Answers Viewqa JSP-Servlet Printing the integers before and after
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Tan BS
Printing the integers before and after
1 Answer(s)      4 years and 11 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

November 11, 2009 at 2:56 PM


Hi Friend,

Try the following code:

<%@ taglib uri="http://java.sun.com/jstl/core_rt"; prefix="c" %>
<%@ page import="java.util.*"%>
<% Random r=new Random();
int num = r.nextInt(10);
System.out.println(num);
int pno=num-1;
int nno=num+1;
%>
<html>
<body>

<c:set var="guess" value="<%=num%>"/>
<b>Random Numbers is </b>
<c:out value="${guess}"/>

<br/>
<c:if test="${(guess %2== 0)}">
<b>It is an even number lies between <%=pno%> and <%=nno%></b><br/>
</c:if>
<c:if test="${(guess %2!= 0)}">
<b>It is an odd number lies between <%=pno%> and <%=nno%>.</b><br/>
</c:if>

</body>
</html>

Thanks


Related Tutorials/Questions & Answers:
Printing the integers before and after - JSP-Servlet
Printing the integers before and after  Hi, I'm trying to print out the integers before and after generated random number, and also stating it as either even or odd, but it does not seem to work. Pls advise on my code below
there extra space before or after my table.
there extra space before or after my table.  Why is there extra space before or after my table
Advertisements
integers
integers  an application that finds the smallest of several integers. assume the first value read specifies the number of values to input from the user. please help
INTEGERS
application that will input the kms driven and litre of fuel used (both as integers
Updating variables in a loop? and only printing certain messages after the first iteration?!
Updating variables in a loop? and only printing certain messages after the first iteration?!  I've written a program that reads two values. I... and ratios. So effectively at every calculation except the first, I would be printing
Sum of integers
the user and displays i) the sum of all even integers between 1 and the input value, both inclusive. ii) The sum of all odd integers between 1 and the input value both inclusive Example: User enters 7. Sum of even integers = 2+4+6 = 12 Sum
Integers separated by a ", " in a string
Integers separated by a ", " in a string  How do I get integers separated by a ', ' in C++ in a string? Ex. string=1, 2, 3; //something to find the integers and put them in array a cout< output: 123   Hi Friend
printing in swing
printing in swing  How can i print payslip in swing
applet printing
applets gridwise and in each applet i am drawing some graph so while printing whole... but while printing it is not getting printed on paper and rest everything it is printing
Create After Update Trigger in SQL
Create After Update Trigger in SQL       After Trigger in SQL is fired before update... illustrate an example from 'Create After Update Trigger in SQL'. In order
printing in java
printing in java  hello i want to print a jInternalframe containing some lebels,but my printer sent me a paper with the following written on it: please what is the problem
how to find [count the number of integers whose value is less than the average value of the integers]
how to find [count the number of integers whose value is less than the average value of the integers]  Construct an algorithm that will prompt... of 999 is entered. After the sentinel has been entered, display the total payroll
Printing stars
Printing stars  I am a beginer and i have one assignment which couldnt give me any idea how to do it..The Question is "Get a string "001222014654" and print o/p as 0 - * 1- ** 2- * 4- ** 5-* 6-* I dont know how to split
Printing numbers up to N into a file
Printing numbers up to N into a file  I'd like to print the first N integers, that is, "1, 2, 3, 4, ..., N-1, N", say N equals 1000, or 10000 or whatever. I'd also like to have the result stored as a file instead of having
Program to read 2 integers using oops concepts
Program to read 2 integers using oops concepts  Write a program to read two integers with the following significance. ? The first integer value... notation, in this case 1630 which is the time 3 hours and 45 minutes after 12.45.
Java program for printing document
Java program for printing document  can u send me the java program for printing the office document? email: ibrahimbest@gmail.com
printing java series
printing java series  * *** ***** ******** ***** *** *   Post the format properly
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
java matching array of integers - Java Beginners
token is assigned a vlaue in integers and stored in an array. the consecutive array of integers occurring similarly have to be found out. and depending upon... for finding similar consecutive array of integers
Printing server information
Printing server information  Hello, I am learning PHP language. I trying to fetch the server Information Print. How could i will printing the server... connected to your PC? This it best example for the Printing server Information
printing example - Java Beginners
printing example  Is it possible to print java controls using print method? My problem is to print a student mark list using java? The mark list should like that of university mark list
What is 3D Printing?
3D printing is one of those technologies that made manual job with the objects... used to know and interact with just a few decades before has changed beyond... and in the meantime we lose the erstwhile sense of solid sensory reality. 3D printing
Java Printing - Java Beginners
Java Printing  Can anybody plz help in giving the code for printing the contents of JPanel.. It contains JLabels and JTextFields only.. Plz.. Its urgetn.. Printing means sending the document to the Printer..  Hi Friend
printing hollow square
printing hollow square  Write an application (PrintingSquares.java) that prompts the user to enter the size of the side of a square, then displays a hollow square of that size made of asterisks. Your program should work
how printing landscape?
how printing landscape?  I have code which print some data from data base with "drawString()" and it works correct when I chose "Portrait" from "Print Dialog", but it does not work if chose "Landscape". Is any way to print
Printing ArrayList - JSP-Servlet
Printing ArrayList   I have a code in servlet like this ArrayList total = new ArrayList (); session.setAttribute("efg",total); RequestDispatcher rd; rd = request.getRequestDispatcher("/checkout.jsp"); rd.forward
validate parameter before using it
validate parameter before using it   How to validate the parameter before using it in JSP
convertion before downloading
convertion before downloading  convert zip file which is in server to doc while before downloading
printing series in java
printing series in java  1 123 12345 1234567 12345 123 1   Here is a code for the following pattern: 1 123 12345 1234567 12345 123 1 class Pattern{ public static void main(String[] args
Printing 2 arrays
Printing 2 arrays  Hi, I have 2 arrays: String [] head = {"Name", "Date of birth", "PPS number"}; String [] personal= {value1, value2, value3}; I want this 2 arrays to be printed out in the following manner: head[0] tab
 

 

 

DMCA.com