Help with do loop
do{
if((orderType != 'g') || (orderType != 'w')){
System.out.println("Please enter g or w only.");
}while((orderType == 'g') || (orderType == 'w'));
I need help with this loop... I have to make sure it will be able to pop the input back after the invalid input... i tried to fix it...wont stop and stay in same loop till it gets the valid before go to other loop... how? am i missing something?
I know you've already been answered, but just a bit more...
if((orderType != 'g') || (orderType != 'w'))That would always be true. All characters are either not equal to 'g' or not equal to 'w'.
'x' : neither 'g' nor 'w'. Evaluates to true.
'g' : not 'w', still evaluates to true.
'w': not 'g', still evaluates to true.
Similar Messages
-
Im trying to create a while loop that outputs the revers of a string, eg nice one
would be "eno ecin" Assuming i already have declared a variable intital string that holds the string, how do i go about this does anyone have any problem solving techniques. The charAt method needs to be used.i have a exam on saturday and it was a previous exam question that im trying to get help with i need to understand the course material thanks, i know how to use while loops but have trouble getting my head around this question. ill show you my code however i know its completely wrong.
now i know i hvae to use the charAt method to return a character located at the integer i
so i must go down after each case has been tested true therefore i want i=i-1;
until i=0;
String initialString="tucan";
int i=initialString.length();
while(i>0)
return charAt();
i=i-1;
} -
Need help with while loop format
I'm building a form - everything works but I would like to change the way the data is output into the table.
In other scripting languages, like PHP, you had 2 different ways of dealing with a loop:
<?
do while xyz
do something here
?>
- OR -
<? do while xyz:?>
do something here
<?end while ?>
I would like to do something similar to the 2nd example in .jsp but I'm not sure of the format or how to stop the loop. From the tutorial, I'm using
<%
while(SQLResult.next())
UId = SQLResult.getString("uid");
FName = SQLResult.getString("fname");
LName = SQLResult.getString("lname");
out.println("<tr><td>" + UId + "</td><td>" + FName + "</td><td>" + LName
+ "</td></tr>");
%>
Could anyone point me in the right direction? I'd prefer it if I didn't have to build the table like this if I don't have to but haven't found anything anywhere telling me otherwise.
Thanks so much.
BobSorry - the answer was in JSP:Java Server Pages by Barry Burd. I had just gotten the output format wrong.
-
Please Help With A Loop Using Vectors?
I am developing a swing application and this loop has me completly stumped I have not worked with vectors alot, nut I have never seen this happen in a loop before:
I am just going to post the loop because that is where this problem is happening.
What I want to do is loop through CAT X amount of times and
have an inner loop for SUBCAT X amount of times.
fs is a formattedString class I have and eventually this text is appended to a JTextArea.
Here is the Loop:
Vector CAT = new Vector();
Vector SUBCAT = new Vector();
CAT = getCategories(Department);
for (int i=0; i<CAT.size(); i++){
String Category = CAT.elementAt(i).toString();
fs.append("\nCategory: ",11);
fs.append(Category,65);
SUBCAT = getSubCategories(Category);
}//End CATEGORY
The part where I am completely stumped is, if I comment out the SUBCAT= part then the Text displays fine. If I dont it will just display the first string in the CAT Vector I have done a try and catch to see if there is an exception being thrown but there is none. The getSubCategories() method works fine b/c it is working at other parts of my program. (It Returns a Vector BTW). So commenting it out should really make no difference.
Can anyone help me with this????
Thanks in advanceI will post what my output is in each scenario and maybe you can better understand what I am explaining:
SCENARIO 1::::::::::::::::::::::::::::
for (int i=0; i<CAT.size(); i++){
fs.append("\nCategory: ",11);
fs.append(CAT.elementAt(i).toString(),65);
}//End CATEGORY
Category: A Collars
Category: Access Door
Category: Aluminum
Category: Anchors Drop In
Category: Bits
Category: Blades
Category: Bolts, Nuts, Pins and Rivets
Category: Bolts, Nuts, Pins, and Rivets
Category: Canvas Connection
Category: Caps
Category: Caulking
Category: Copper
Category: Duct Mate
Category: Ells
Category: Flat Bar
Category: Flex Duct
Category: Galvanized
Category: Grills
Category: Insulation
Category: Iron
Category: Miscellaneous
Category: Pipe
Category: Reducers
Category: Return Air Panels
Category: Rings
Category: Rod
Category: Slide Gates
Category: Spin Ins
Category: Stainless Steel
Category: Stick On With Damper
Category: Tape
Category: TDC
Category: Tees
Scenario 2:::::::::::::::::::::::::::::::::
Category: A Collars
for (int i=0; i<CAT.size(); i++){
fs.append("\nCategory: ",11);
fs.append(CAT.elementAt(i).toString(),65);
SUBCAT = getSubCategories(CAT.elementAt(i).toString());
}//End CATEGORY
Now do you see:
The SUBCAT = getSubCategories(CAT.elementAt(i).toString()); should not be affecting the loop. It should just be assigning a new Vector to SUBCAT. I know that it is missing the inner loop in this example, but this is how I found out the loops where not working right. -
Hi
I've been at this for over 24 hours. I have a small video
clip which is embedded in DW and uploaded...
http://www.forpetsake.ca/about2.html
Originally I purchased this ,mov from istockphoto.com and
used QT pro to convert into a .flv. Once converted I brought it
onto the Flash stage. In published settings I selected the 'loop'
option and then exported out to a .swf. Once I embedded this .swf
into my DW page, I uploaded all to my server including the .html
created with the .swf, in fact I uploaded the .flv/.swf/.html into
a seperate folder on my server.
All I want to do is set this movie to loop, maybe pause for a
couple seconds before each loop.
I'm a simple person who only understands simple explanations.
Can someone please walk me through the steps in Flash CS3 to
get this short clip to loop.
ps" The Property Panel selectors (loop-autoplay) make no
changes whatsoever in DW CS3 with respect to this video.
Thanks in advance for any help you can provide.If you're importing the FLV file into a SWF file (which is
not recommended these days), then just add a gotoAndPlay(1) action
to a keyframe you add at the very end of your Flash timeline.
If, however, you use the FLVPlayback component, you can write
ActionScript to listen for the "complete" event and tell the video
to restart when that event is detected.
Also, use SWFObject (
http://blog.deconcept.com/swfobject)
to embed a SWF into your HTML document. Dreamweaver and Flash's
detection scripts aren't as good. (my two cents)
HTH. -
I'm a beginner. I'm trying to get this output
Initial number of stars:
7
Here's my program. What's wrong with it? Please help
import java.io.*;
class starWedge
public static void main (String[] args ) throws IOException
int numStars; // the number of stars
int row ; // current row number
int star; // the number of stars in this row so far
BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
String inputData;
// collect input data from user
System.out.println( "Initial number of stars:" );
inputData = userin.readLine();
numStars = Integer.parseInt( inputData );
row = 1;
while ( row <= numStars )
star = 1;
star = numStars - star;
System.out.print("*");
star = star + 1;
System.out.println(); // end each line
row = row + 1;Okay the one thing that I see immediately is that your while loop never actully exits. Not once. Why? Well simple your exit condition is the row <= numStars, yet nither numStars nor row actually change their values within the loop. In short row always equals 1 and thus never is equal to greater than numStars and the while loop does not terminate.
Second thing is that your star drawing logic is not correct. Meaning you have not told to draw the specific number of stars in one given line. For starters the System.out.println() command should be in the loop not outside it. For your purposes a for-loop nested within a while-loop is much better.
If you think you know what's wrong your program than read no further and go try it on your own. But if you still have no clue below is my modification of your code that actually produces the pattern you want, it might provide you with more hints.
import java.io.*;
class starWedge{
public static void main (String[] args ) throws IOException{
int numStars; // the number of stars
int row ; // current row number
int star; // the number of stars in this row so far
BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
String inputData;
// collect input data from user
System.out.println( "Initial number of stars:" );
inputData = userin.readLine();
numStars = Integer.parseInt( inputData );
row = 1;
while (numStars > 0){
for(star = 1; star<=numStars; star++){
System.out.print("*");
numStars = numStars - 1;
System.out.println(); // end each line
} -
Hello let me first explain what im trying to achive:
I want a moving square that you control with the arrow keys on the keyboard. It has to be smooth ie able to move fast without looking like its jumping and it has to be able to move diagonaly aswell. Think of that arcade game Raiden ...you know the birds-eye view plane flying game...another thing! I'd prefer if it didnt use timers - i made one already using 4 timers and it works great but 4 timers is a little extreme - SO NO TIMERS !
I was thinking while loops, but i cant seem to get it working. I dont want to put in all the code so ill just say that I have 4 booleans: up, down, left right and the following code:
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
up = true;
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
down = true;
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
left = true;
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
right = true;
repaint();
For the KeyReleased part i have the same as above exept it sets the booleans to false.
Soooo in theory if i set up a while loop like this (using the up direction as an example) :
while (up == true) {
[move square up]
So therefore when i press and hold the up arrow the loop will keep going untill i realease it right? WRONG ! it just keeps repeating indefinatly and it doesnt even do the " [move square up] " bit. I put a System.out.print in the loop to test and it kept printing out the message but it still didnt do the actual " [move square up] " bit.
Im not sure if im putting the while loop in the right place either....If anyone has any idea on how to use while loops in this way please heeeelp ! Its so annoying because it just doesnt work ive tried so many ways...
any help would be greatly apreciated !!!!Maybe you want something like this? You have to pause during the loop to allow for other events to happen, like if y ou release a key or whatever.
while( true )
if( up ) moveUp();
else if( down ) moveDown();
if( left ) moveLeft();
else if( right ) moveRight();
try
Thread.currentThread().sleep(10);
catch( InterruptedException e )
System.out.println( "Thread interrupted!");
} -
Need help with while loop and shift registers
I have a large data set and need to read in the data at maybe 200 samples at a time, process these samples through my VI, and have it append and concatenate a separate lvm file. The part where I am confused is the shift registers. How do I limit the number of samples read in an iteration? How do I get the while loop to stop when all the data are read in?
I've attached my diagram, maybe there is something wrong with my technique?
Solved!
Go to Solution.
Attachments:
shiftreg.JPG 56 KBThis will give you an idea. There are plenty of other (probably more efficient) methods. This is a basic, quick and dirty solution to help you grasp the overall concept.
Using LabVIEW: 7.1.1, 8.5.1 & 2013
Attachments:
ShiftRegLoop.JPG 54 KB -
Need help with infinite loop in recovery mode in Creative Zen 20
hi,
I'm having this problem with my Creative Zen 20 GB:
When I turned it on, it goes immediately to the rescue/recovery mode. Not sure why. Will do that even when I reset the device.
So, I selected cleanup. After cleanup, it remained showing the menu of the recovery mode. I selected reboot. After reboot, it went back to the rescue/recovery mode. And it goes on and on like an infinite loop.
Finally, I decided to do a formatAll. Again, it remained in the recovery mode menu after the formatAll action. After reboot, it again went back to the rescue/recovery mode.
I have never updated the firmware. So, I thought maybe that will help. However, when I connected the device to my PC, the device went to rescue/recovery mode and the PC could not detect the device connected via USB. In short, I am currently not able to do anything at all with the device except charging it.
Would appreciate help/advise.
Tks in advance.huggiebear wrote:
I connected the device to the PC and after the PC tried to load the library, it said "Player is not connected".
What library are you loading? After you have run that reload os option, you need to connect the player to the computer and run the firmware update software. If you haven't download that, you can go to the download section and download it. If all else fail, the player is probably faulty and you would need to get in contact with Customer Support then.
Jason -
Hi all, I have this annoying problem and I am looking for any suggestions.
I have 2 select boxes. One is for all available users, and second - for selected users (designated as admins). The list of all users is available in a collection (2 properties userId and userName displayed in the code below). The list of admins contains only userId (as strings).
I have no problem with populating selected users (admins) list, reusing pretty much the same logic below, but I cannot find a way to break out from the nested loop once the match is found, to avoid repetitions leading to incorrect display of results.
<select name=available>
<c:forEach items="${users}" var="user" varStatus="outer">
<c:forEach items="${adminIds}" var="adminId" varStatus="inner">
<c:if test="${user.userId!=adminId">
<option value="<c:out value="${user.userId}" />"><c:out value="${user.userFullName}"/></option>
</c:if>
</c:forEach>
</c:forEach>
</select>
<select name=selected>
<c:forEach items="${users}" var="user" varStatus="outer">
<c:forEach items="${adminIds}" var="adminId" varStatus="inner">
<c:if test="${user.userId==adminId">
<option value="<c:out value="${user.userId}" />"><c:out value="${user.userFullName}"/></option>
</c:if>
</c:forEach>
</c:forEach>
</select>Can anyone help, please? I am also restricted to JSP 1.2Double post: http://forum.java.sun.com/thread.jspa?threadID=707950&tstart=0
-
Weird Problem- Help With Logic Loops
Hi all,
I've been using Logic Express 8 for about 2 years and I've got a pretty good handle on things. However I keep having this small little problem and usually restarting the software fixes it, but not this time.
My problem is this: I'm trying to make some beats using software instruments. So I click on "Drums and Percussion" then "Ultrabeat" then choose my drum kit. I start punching in my beats but Logic is playing some Apple Loop on top of it! Theres no notes on the track and yet it still plays this random beat! I can adjust the tempo and the beat adjusts to it.
The problem is there is nothing there. Its a blank track, but this beat keeps playing.
I used to just restart the program when it happened and it usually took care of it, however it won't fix it this time.
I know it's probably some check box I don't have clicked or something but if someone could help me out, I'd be very appreciative.
Thanks,
JoshAh yes!
Thank you JG99!!!
I forgot to go into the Ultrabeat menu, and turn off the "example beat" that they give you. I knew it was some checkbox that I didn't unclick or click.
Thank you sir, you are a gentleman and a scholar. -
In the attached picture inside the red circle is where I need help. I'm trying to turn on 4 relays, it currently works but all the relays come on at the same time I need a 500ms pause between each relay and I can't seem to figure it out. I would assume some kind of for loop would work I'm just not sure how to index the "Fan 1 switch", Fan 2 switch","Fan 3 switch", Fan 4 switch" into an array.
Any help would be much appreciated
Thanks,
Attachments:
help1.jpg 251 KB
fanctrl_with_sound_detec1.vi 61 KBHere's one example, using just a numeric indicator as the state control. The State Machine is only slightly more involved.
This example also shows one way to use an array to set your booleans to True/False.
Good luck!
Message Edited by LabViewGuruWannabe on 01-28-2008 12:36 PM
Attachments:
RelaysON-OFF.vi 47 KB
RelaysON-OFF-BD.png 46 KB
RelaysON-OFF-FP.png 32 KB -
Sorry for the "Noob"-ness on this one. I am working on a program for class and I am having a problem with a while loop. So I opened a new document and began to code a while loop that is basic to test my while looping skill. Apparrently, I have none. Can anyone tell me why this While Loop will not work:
public class test
public static void main(String[] args)
int LoanTerm = 0;
while (LoanTerm < 3);
System.out.println (LoanTerm);
LoanTerm++;
Thanks.
FatherVicto explain, the ; means that the while loop body is empty, and you will just spin forever testing whether LoanTerm < 3, without doing anything else.
-
I need help with a loop within an hour
I need to make a loop that gives 100, 10, 1000, 100, 10000, 1000...
I can use a for loop, if loop, while loop, and do while loop.
Thankswarnerja wrote:
sharkura wrote:
warnerja wrote:
sharkura wrote:
Sorry warnerja. I know I should have done the same. I just couldn't help myself. I need to keep telling rubbish.
:D
¦ {ÞIt's not too late to edit your spoon-fed solution, though the OP may have seen and copied it by now.And you know this isn't going to make the OP a programmer, unless he/she/it changes his/her/its stripes.
¦ {ÞYes, but its laziness will continue to be encouraged more than it should.Nah. It'll crash and burn on the next assignment.
¦ {Þ -
Help with for loop and remove-item command
Hi all here is the code so far
$a = Get-Content C:\Users\cody-horton\Desktop\test.txt
for($i=0;$i -lt $a.Length;$i++){
#$temp = [int32]::Parse($a[$i])
Remove-Item '\\ceit2551202x0'$a[$i]'\C$\Program Files\MATLAB\R2013a\*' -Force
I have a text file with a few number in it that i want to get. They are in the array $a but I'm getting an error that says a positional parameter cannot be found that accepts argument '53' (it does this for all the numbers in the array.) I know in java you
could have something like this string + int + string.
I'm not sure what to do I also tried to parse it with no luck. Thanks any help is appreciated.Your issue is with the path for Remove-Item, it is not complete so try this
Remove-Item "\\ceit2551202x0$($a[$i])\C$\Program Files\MATLAB\R2013a\*" -Force
I am unable to test, so I would add the -WhatIf switch to make sure it outputs what you expect
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
Don't Retire Technet
Maybe you are looking for
-
Processes in v$process which do not exist in v$session(help)!!
Hi, all. The database is 2 node RAC database (10.2.0.2.0) on 32 bit windows 2003 EE SP1. Our database is suffering "CKPT hang" from time to time. I checked v$process and v$session on both node by the following sql. select addr,pid,spid,username, prog
-
Hello, I'm trying to affect my flash movie from HTML. For example, if I have a google adsense module, and I want to trigger something in flash each time that link is hit, how would I go about doing that? Any help would be much appreciated!
-
I cannot open a file with suffix .ra
i cannot open a file with suffix .ra
-
No Predicate Information showing in typical display
same sql statement, in other environment, when I display plan with dbms_xplan, it shows predicate information, only in one environment, not showing, even I used ALL option, compared two environment, there is no difference, what is could be possible r
-
Sould I give up on MAC OS leopard, because of error 36?
I just bought 2 new elements western digital 320 gig hardisk... THis is what happened. I was trying to load movie files in both of my HArd disk. I loaded the first harddisk from a PC successfully, .. Then I bought a new MACbook with leopard, 2 gig pr