hey guys, im having problem converting this to a while loop.

   int lineB;
        int starB;
        for(lineB=1; lineB<=10;lineB++)
        {
            for(starB=10; starB>=lineB; starB--)
                System.out.print("*");
            System.out.println();
        }
        System.out.println();

Can it be written like this?

int lineB=1;
int starB=1;
while(lineB<=10)
{
    while(starB>=lineB)
    {
     StarB--;
     System.out.print("*");
     System.out.println(); 
     }
   lineB++;
}

Edited 3 Years Ago by Dani: Formatting fixed

Did you test both the coding? If the result for both coding are the same, then there should not be any problem in the conversion.

Thanks guy i got the code to work. heres the final code!

int lineB=1;
        while(lineB<=10)
        {
            int starB=10;
            while(starB>=lineB)
            {
                starB--;
                System.out.print("*");
            }
            System.out.println();
            lineB++;
        }

Edited 3 Years Ago by Dani: Formatting fixed

number = 10;
sum = 0;
for (var i=1; i<= number; i++) {
sum = sum + number;
}
document.write("sum = " + sum);


number = 10;
for (var i=number; i > 0; i--) {
if ( i%2 == 1)
document.write(i);
}


product = 1;
number = 5;
for (var i=1; i < (number+1); i++) {
product = product * number;
}
document.write(product);


for ( var i=1; i<= 5; i++) {
for (var j=1; j<=3; j++) {
document.write("*");
}
document.write("<br />");
}

First of all this is a 11 month-old thread.
Second, do you understand why what you have written is wrong? Also the OP has already figured out his problem. You hardly made any contribution

int lineB=1;
int starB=1;
while(lineB<=10)
{
starB=10;
while(starB>=lineB)
{
starB--;
System.out.print("*");
System.out.println();
}
lineB++;
}
dis is the corrected code!!!!!!

First of all this is a 11 month-old thread.
Second, do you understand why what you have written is wrong? Also the OP has already figured out his problem. You hardly made any contribution

sry i didn't see dat it was 11 months older now
sorry ..........

sry i didn't see dat it was 11 months older now
sorry ..........

Also the guy was trying to cheat at an online exam. If you look at a recent post he says: "I want the solution within 30 minutes or I will fail".

Meaning that despite your good heart, you shouldn't post the solution, because this is against the forum rules. We do not give ready solutions just because someone has asked for it.
We only help those that show an effort; we don't hand in their homework.

Keep trying to help people and don't let this thread get you down

Also the guy was trying to cheat at an online exam. If you look at a recent post he says: "I want the solution within 30 minutes or I will fail".

Meaning that despite your good heart, you shouldn't post the solution, because this is against the forum rules. We do not give ready solutions just because someone has asked for it.
We only help those that show an effort; we don't hand in their homework.

Keep trying to help people and don't let this thread get you down

k i will take care of it in future.......

<html>
<head>
<script type="text/javascript">
function inputoutput()
//assumes: document.meow.textbox.value
// results: output the number inputed by the user
{
var n;
n = document.meow.textbox.value
alert(" " + n);
}
</script>
</head>
<body>
<form name="meow">
<input type="text" name="textbox" size="10" value="" />
<br/><br/>
<input type="button" value="click here" onClick="inputoutput();" />
</form>
</body>
</html>

Comments
Disgusting how many times you need to be told to not revive old threads with lame posts.

A request to the moderators please lock this thread as I doubt anything related to original post is bound to be added here anymore and for no reason at all is being brought on the first page repeatedly.

convert for loop to a while loop
for count= 1 to 50
display count
End for

convert for loop to a while loop
for count= 1 to 50
display count
End for

while (notPayingAttentionToTheRules) {
  ignore();
}

Start a new thread if you have a question. Show some effort if you would like assistance.

Edited 7 Years Ago by Ezzaral: n/a

This article has been dead for over six months. Start a new discussion instead.