# JAVA need HELP!

**URL:** <https://forum.kirupa.com/t/java-need-help/260262>\
**Category:** programming\
**Created:** [May 13, 2008, 10:46pm UTC](https://forum.kirupa.com/t/java-need-help/260262 "2008-05-13T22:46:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![masterxox](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@masterxox](https://forum.kirupa.com/u/masterxox)\
**Post date:** [May 13, 2008, 10:46pm UTC](https://forum.kirupa.com/t/java-need-help/260262/1 "2008-05-13T22:46:50Z")

</div>

[COLOR=Red]My assignment is input 5 integer (have to show in xhtml) and deter main largest and smallest Integer. I am including the script:[/COLOR]

\<?xml version =“1.0”?\>  
\<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”  
“[http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd](http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd)”\>

\<!-- Fig. 7.6: welcome5.html–\>  
\<!— Using Promt Boxes --\>

\<html xmlns =“[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)”\>

\<head\>

\<title\> Using Promt and Alart Boxes\</title\>

\<script type=“text/javascript”\>

\<!–

var x,y,z,o,p, result;  
var xVal, yVal, zVal, oVal, pVal;

// read the name from the prompt box as a string  
xVal = window.prompt(“please enter your first integer”, “0”);  
yVal = window.prompt(“please enter your second integer”, “0”);  
zVal = window.prompt(“please enter your first integer”, “0”);  
oVal = window.prompt(“please enter your first integer”, “0”);  
pVal = window.prompt(“please enter your first integer”, “0”);

x=parseInt (xVal);  
document.writeln("\<br/\>First number is: " +x);  
y=parseInt (yVal);  
document.writeln("\<br/\>Second number is: " +y);  
z=parseInt (zVal);  
document.writeln("\<br/\>Third number is: " +z);  
o=parseInt (oVal);  
document.writeln("\<br/\>Fourth number is: " +o);  
p=parseInt (pVal);  
document.writeln("\<br/\>Fifth number is: " +p);

static int smallest(int x, int y, int z) {  
if (x \<= y && x \<= z) {  
return x;  
}  
else if (y \<= x && y \<= z) {  
return y;  
}  
else  
return z;  
}

: I gave uppp

//–\>

\</script\>

\</head\>

\<body\>  
\<p\> click Refresh to run this script again.\</p\>  
\</body\>

\</html\>

---

<div class="post-metadata">

**Author:** ![kdd](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kdd](https://forum.kirupa.com/u/kdd)\
**Post date:** [May 14, 2008, 4:56am UTC](https://forum.kirupa.com/t/java-need-help/260262/2 "2008-05-14T04:56:25Z")

</div>

Hey man.

1. This is JavaScript, not Java. 🙂
2. I won’t give you a solution. If I do, you won’t learn how to code. muhwahwahwa. :insert evil laugh smiley here:
3. Here’s the pseudo code:

```auto

<script type="text/javascript">

numArray = create a new array with size of 5;

a for loop from i = 0 to i < 5, stepsize 1.
{
prompt user for a value, and insert it into i-th index of the numArray.
}

//find min
minNum is 0-th element of numArray.
a for loop from i = 1 to i < 5, stepsize 1.
{
if the i-th element is less than minNum, replace minNum with this i-th element.
}

//please do max on your own. (left to reader as an exercise. haha)
</script>

```

Do the parseInt stuff also, I left that out… (like type-checking stuff).

And man, don’t give up too soon. It’s way too soon to give up! You gotta try harder man…

---

<div class="post-metadata">

**Author:** ![masterxox](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@masterxox](https://forum.kirupa.com/u/masterxox)\
**Post date:** [May 14, 2008, 5:11am UTC](https://forum.kirupa.com/t/java-need-help/260262/3 "2008-05-14T05:11:00Z")

</div>

10 points for MOHAMMAD REZZA && PASS THE TEST55+10=65  
\<?xml version =“1.0”?\>  
\<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”  
“[http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd](http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd)”\>

\<!-- Fig. 7.6: welcome5.html–\>  
\<!— Using Promt Boxes --\>

\<html xmlns =“[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)”\>

\<head\>

\<title\> 10 points for MOHAMMAD REZZA && PASS THE TEST55+10=65\</title\>

\<script type=“text/javascript”\>

\<!–

var x,y,z,o,p,maxValue,minValue;  
var xVal, yVal, zVal, oVal, pVal;

// read the name from the prompt box as a string  
xVal = window.prompt(“please enter your first integer”, “0”);  
yVal = window.prompt(“please enter your second integer”, “0”);  
zVal = window.prompt(“please enter your first integer”, “0”);  
oVal = window.prompt(“please enter your first integer”, “0”);  
pVal = window.prompt(“please enter your first integer”, “0”);

x=parseInt (xVal);  
document.writeln("\<br/\>First number is: " +x);  
y=parseInt (yVal);  
document.writeln("\<br/\>Second number is: " +y);  
z=parseInt (zVal);  
document.writeln("\<br/\>Third number is: " +z);  
o=parseInt (oVal);  
document.writeln("\<br/\>Fourth number is: " +o);  
p=parseInt (pVal);  
document.writeln("\<br/\>Fifth number is: " +p);

{  
var maxValue;  
if (x\>y)  
{  
maxValue =x ;  
}  
else  
{  
maxValue = y;  
}  
if (y\>z)  
{  
maxValue =y ;  
}  
else  
{  
maxValue = z;  
}  
if (z\>o)  
{  
maxvalue =z;  
}  
else  
{  
maxValue = o;  
}  
if (o\>p)  
{  
maxvalue =o;  
}  
else  
{  
maxValue = p;  
}

```
{
    document.writeln("&lt;br/&gt;The MAXIMUM number is: " +maxValue);
}

```

}

{  
var minValue;  
if (x\<y)  
{  
minValue =x ;  
}  
else  
{  
minValue = y;  
}  
if (y\<z)  
{  
minValue =y ;  
}  
else  
{  
minValue = z;  
}  
if (z\<o)  
{  
minValue =z;  
}  
else  
{  
minValue = o;  
}  
if (o\<p)  
{  
minValue =o;  
}  
else  
{  
minValue = p;  
}

```
{
    document.writeln("&lt;br/&gt;The MInImum number is: " +minValue);
}

```

}

//–\>

\</script\>

\</head\>

\<body\>  
\<p\> click Refresh to run this script again.\</p\>  
\</body\>

\</html\>
