while-loop

While loop to check character input

Deadly 提交于 2019-12-13 04:43:08
问题 I am trying to accept input from the user in the form of a character. I have that working but I need to check and make sure it is one of 6 characters (H, h, S, s, L, l). I have a while loop but as soon as add more than one character statement to it, the loop gives the error for every value that should be correct. Here is the function: private static char getHighLow(Scanner keyboard) { System.out.println("High, Low, or Sevens (H/L/S): "); String choiceString = keyboard.next(); char choice =

TTS play silence in a for-loop doesn`t work

眉间皱痕 提交于 2019-12-13 04:41:34
问题 I want to add a pause button to my TTS-app. I am trying to do this with a while-loop, which should playSIlence. It isn't working, but I can't find my mistake. my boolean: boolean pausegedrückt; for-loop: for (int i = 1; i < anzahl+1; i++) { while (pausegedrückt==true) { tts.playSilence(1000, TextToSpeech.QUEUE_ADD, null); } String str = String.valueOf(i); tts.speak(str, TextToSpeech.QUEUE_ADD, null); tts.playSilence(3000, TextToSpeech.QUEUE_ADD, null); } my onCheckedChanged @Override public

Scope of variable inside do-while loop

大兔子大兔子 提交于 2019-12-13 04:38:08
问题 I'm trying to loop through an entire program if the user inputs "y" or "Y" when they are prompted at the end of the program, but I'm getting a "cannot find symbol - variable response" error since the variable I declared is inside the do-while loop, therefore I suppose I can't use it in the condition of the do-while loop. Is there any way to get around this problem and still be able to loop through the program if the user inputs a "y" or "Y"? This is all in the main method and getFileRunStats

How do I use a while loop with an onTouch function? (Android)

跟風遠走 提交于 2019-12-13 04:30:11
问题 Well, I have been looking up answers, but none have worked for me. I have a button that when it is HELD DOWN, is suppose to continue to move an image across the screen. But for some reason, it just keeps freezing my kindle when I tap the button. I think the thread is part of the problem, but i'm unsure. Here is the code: package com.evilsea.darkages; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; import android.view.MotionEvent; import android.view.View;

PHP - Why while(mysql_fetch_array(mysql_query())) loops?

爱⌒轻易说出口 提交于 2019-12-13 04:24:19
问题 So I have the code: $sql = "SELECT * from users WHERE level = 2"; $result = mysql_query($sql); while($write = mysql_fetch_array($result)){ echo ''.$write['username'].''; } I want to make it more simple so I do: while($write = mysql_fetch_array(mysql_query("SELECT * from users WHERE level = 2"))){ echo ''.$write['username'].''; } Why the first code isn't infinity looping and the second code is? 回答1: the first code iterates a resource given by mysql_query($sql); the second iterates the query

How to use sentinel values different from input & sort list by feature?

时光怂恿深爱的人放手 提交于 2019-12-13 04:18:42
问题 I'm learning beginner python and there's one question that I'm stuck on. The question involves asking user input for any amount of mushrooms that they have picked, entering a weight, and then sorting them according to the user input. For this, a list and a while loop is needed to append the inputs into the list. Currently I am trying to implement a sentinel value that will stop the while loop after all of the user inputs have been entered, but setting the sentinel as "STOP" conflicts with the

Create unique Form input ID's and input name's in while loop

ⅰ亾dé卋堺 提交于 2019-12-13 04:08:48
问题 I have a table being built and populated by a while loop. the while loop is fetching and displaying results from a mysql database. As per the below code, there is a checkbox on each line, value equal to a unique identifier loadnumber . the next column is a input box with name and id of correctedweight . again the value of this is predefined by the MySQL data value. the next column is a select box named correctedtrailer and again the selected value is equal to the database result. My sql query

Java double equality

天大地大妈咪最大 提交于 2019-12-13 04:06:43
问题 I'm having a problem in comparing doubles. The comparison is responsible for stopping a while cycle. The code runs fine, but then suddenly, the cycle never stops. The values from centroidList's dimVal are being compared to the temp variable which is calculated(the bold bit). The code always enters the if, it doesn't matter if I use "!=" or "==". Printed out the values, they are exactly the same. What is wrong? package clusters; import java.util.LinkedList; public class KMeansV2 { LinkedList

Long term instrument data acquisition with Python - Using “While” loops and threaded processes

若如初见. 提交于 2019-12-13 04:05:48
问题 I will have 4 hardware data acquisition units connected to a single control PC over a hard-wired Ethernet LAN. The coding for this application will reside on the PC and is entirely Python-based. Each data acquisition unit is identically configured and will be polled from the PC in identical fashion. The test boxes they are connected to provide the variable output we seek to do our testing. These tests are long-term (8-16 months or better), with relatively low data acquisition rates (less than

PHP getting variables outside while loop

最后都变了- 提交于 2019-12-13 03:36:32
问题 earlier i posted a question about getting a single constant value from a loop and use it outside of the loop (reference : Question). now i'm facing another problem with another while loop. it goes like this: i have a query: $sql = " SELECT alarms.id, alarms.date, clients.name, clients.number, alarms.controller, alarmstype.type, alarms.alarmstatus, alarms.starttime, alarms.endtime FROM alarms INNER JOIN clients ON alarms.clientid = clients.id INNER JOIN alarmstype ON alarms.typeid = alarmstype