while-loop

Total not adding up

Deadly 提交于 2019-12-25 08:29:13
问题 I'm working on a classwork in high school comp sci class and i have come across this problem. the total is not adding. can someone tell me why? import javax.swing.*; public class TimeSheets { public static void main(String[] args) { String loc; String[] day = new String[7]; String time1; String time2; int location; double total = 0; int num = 1; int x = 0; int y = 0; double clock1 = 0; double clock2 = 0; double hour; loc = JOptionPane.showInputDialog(null, "Enter your Work Location");

a NSTimer in While Loop

亡梦爱人 提交于 2019-12-25 08:26:17
问题 Greeting !! The following codes are now I am doing : BOOL bJobDone = NO ; bBrickDropDone = NO ; //global var here !! NSTimer* timer = nil ; while(bJobDone==NO) { if(timer == nil) { timer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(dropBrick:) userInfo:nil repeats:YES]; } if(bBrickDropDone==YES) { bBrickDropDone = NO ; [timer invalidate] ; timer = nil ; if([self MarkBrickBomb]==YES) { bJobDone = NO ; [self dealBomb] ; if([self AllClean]==YES) { bJobDone = YES ;

Python Code-While loop never end

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 08:05:46
问题 I am new to Python.Trying to learn it. This is my Code: import sys my_int=raw_input("How many integers?") try: my_int=int(my_int) except ValueError: ("You must enter an integer") ints=list() count=0 while count<my_int: new_int=raw_input("Please enter integer{0}:".format(count+1)) isint=False try: new_int=int(new_int) except: print("You must enter an integer") if isint==True: ints.append(new_int) count+=1 The code is executing but the loop is always repeating and is not allowing me to enter

Thread.sleep() in while loop doesn't work properly?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 07:59:43
问题 The object is supposed to change modes (movement algorithm) every 5 seconds. I first tried with a while loop but the loop was iterating way too fast. Then I added Thread.sleep(5000) but still my object moves only in one algorithm ( scatterMode ). Here is the algorithm: //LEVEL 1 //scatter for 7s //chase for 20s //scatter for 7s //chase for 20s //scatter for 5s //chase for 20s //scatter for 5s //chase indefinite And here is the code. The constructor and variable declarations are at the bottom

Java objects of classes not returning the same values

你说的曾经没有我的故事 提交于 2019-12-25 07:59:11
问题 I am creating an object of a class from 2 separate classes and both objects are returning different values for the same method. I suspect it may be an issue with the while loop but here are the classes. The main class works, the setup class is the class that is being turned into and object and the game loop class has the object that doesn't return the right values. it returns the values defined at the beginning of setup and not the modified versions. import java.util.Scanner; public class

using while(!feof) with terminating condition ,still it is going in infinite loop in c

让人想犯罪 __ 提交于 2019-12-25 07:59:03
问题 I am coding a program for a library management system as my project in c. I used a while loop along with !feof condition to check the file for book . Since I read that we should not use it, and if we must, we should do it with some break statement and also since I was reading large no. of variables from file, I used found for breaking the while loop. whenever the Target and book.bname will match (using strcmp ), found is set to 1 and while loop will be terminated. This is the logic I used

While loop in jquery of dynamic id and class

僤鯓⒐⒋嵵緔 提交于 2019-12-25 06:46:15
问题 I have have multiple divs' with similar code within it, but also has a unique id within the main div that calls a toggleClass & slideToggle function. I'm trying to create a loop so that I do not have to write similar code for each element. --- working code --- (where numeric value after the id would change) $('#er1').click(function() { $('#er1').toggleClass('but-extra-on'); $('#cr1').toggleClass('but-closerow-on'); $('#er1').next('div').slideToggle('slow'); return false; }); -- not working

Nested For loops, X-mas tree in C

前提是你 提交于 2019-12-25 05:29:09
问题 So I have the task of creating a Christmas tree in C, I know this has been done to death but there are some conditions that have to be meet that leave me beyond confused, I don't even know where to start. So we ask the user for the number of levels(how many lines in the layer) and then the number of layers. Now, each line after the first in each layer will add 2 " * " one to each side of the first( which is just a line with one " * ".) And we do this until the number of levels in the layer is

Combine several SQL querys to one

天涯浪子 提交于 2019-12-25 05:05:54
问题 I know this is probably really simple but I have tried to find some similar examples and failed. The problem is that I would like to list 8 random images from a gallery in a database, sorted by added date. And I have managed to do this, but only with several iterating query's that becomes really slow. So if someone would be so kind to teach me about combining them for faster speed, I guess UNION is the way to go? Here is my working (but slooow code) <?php $latestPictures = mysql_query("SELECT

Guess a number program with Java

妖精的绣舞 提交于 2019-12-25 04:16:12
问题 I am trying to create a program in Java in which the computer randomly guesses a number between 1-100 and allows the user to guess to the number. If the number is lower than the random number the program should say: lower! and if higher, the program should say: higher! If the user guesses the right number, it should say congratulations you guessed the right number in X amount of tries . This is what I have so far, any help would be appreciated! import java.util.Scanner; public class