do-while

QT do while loop

感情迁移 提交于 2020-01-06 07:11:18
问题 I am learning QT these days and I wanted to test do while loop , the actual login works in normally, but in QT the application freezes .. I have defined randnum and guess in the header file ( public ) void MainWindow::on_pushButton_clicked() { srand (time(NULL)); randnum = rand() % 10 +1; do { guess = ui->spinBox->value(); if (guess < randnum) { ui->label->setText("try something big"); } else if (guess > randnum) { ui->label->setText("try something small"); } else ui->label->setText("YAY?");

C++ error with input validation in a do-while loop

跟風遠走 提交于 2020-01-06 03:46:10
问题 I'm creating a very simple number guessing game for a school project and am having trouble with the repeating main menu. I created it using a do-while loop and the problem I'm having is that the menu selection variable is an int , and so when I (or the user) enters a non-int input by accident when selecting from the menu the }while(condition) at the end of the main loop can't catch it and the program repeats infinitely. Conversely if you enter an invalid int at menu selection the program

repeat program function failure in C, scanf related?

有些话、适合烂在心里 提交于 2020-01-06 03:42:14
问题 So I'm trying to ask the user if they would like to repeat my program and I am getting a weird result now and then. It doesn't happen everytime and I havn't been able to figure out what triggers it. To me it looks like it is assigning the 'return' after I enter 'q' to repeatProgram instead of the 'q' but I have no Idea why. The output when it works: to exit enter q, to continue enter y. s you've entered s, that isn't a valid option. The output when it fails: to exit enter q, to continue enter

VB.NET 2008 Application crashing during Do Loop

ε祈祈猫儿з 提交于 2020-01-03 04:54:11
问题 I am writing an application to compare each item on listbox1 to all items on listbox2. If the item is found, then remove it from both lists. The goal is to only have the items that were not found remain on both lists. The problem is, the application just hangs and I never get any results. I looked at my code several times and I cannot figure out what's going on (programming noob I know...). Can anybody help me with this? Code Snippet: Private Sub Button2_Click(ByVal sender As System.Object,

Java do while loop back to the beginning of application

狂风中的少年 提交于 2019-12-25 21:39:46
问题 This question is a follow-up from this link Java SE do while loop issues This is an application asking for a room's name then second prompt to ask for its dimensions to perform some calculations. right after everything has been done, the application should be able to return back to the first prompt asking for the name of room etc. class Room { private String name; private double length; private double width; private double height; public Room(String r, double l, double w, double h) { name = r

Java do while loop back to the beginning of application

帅比萌擦擦* 提交于 2019-12-25 21:38:11
问题 This question is a follow-up from this link Java SE do while loop issues This is an application asking for a room's name then second prompt to ask for its dimensions to perform some calculations. right after everything has been done, the application should be able to return back to the first prompt asking for the name of room etc. class Room { private String name; private double length; private double width; private double height; public Room(String r, double l, double w, double h) { name = r

reading user command to continue does not work

你离开我真会死。 提交于 2019-12-25 12:09:22
问题 I'm Writing a program for Billing System. I'm using do-while loop in my program. And the program is executed according to user input. If the user want to continue the execution, the program will be continue. But I Got a prob in Execution. I was trying my logic in simple do-while loop. The same Problem arises for simple do-while loop also. Problem is: If the input is yes, the program does not get the further input from user. That simple do-while loop is: #include <stdio.h> main() { int c; char

Using a do-while to restart a game in java

爱⌒轻易说出口 提交于 2019-12-25 07:31:19
问题 Please help with the swtich case need for a game public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Please Enter a number"); int day = input.nextInt(); switch(day) { case 1: System.out.println("1 Microphone"); break; case 2: System.out.println("2 Loud Speakers 1 Microphone "); break; case 3: System.out.println("3 Keyboards 2 Loudspeakers 1 Microphone "); break; case 4: System.out.println("4 Java Books 3 Keyboards 2 Loudspeakers 1 Microphone");

ending a do-while loop

允我心安 提交于 2019-12-25 02:25:07
问题 Ok I have a do-while loop that's supposed to end when the use hits 'q' but it is giving me the error message instead please help. package Assignments; import java.util.*; public class assignment3 { public static void main(String[] args) { //Scanner Scanner stdIn = new Scanner(System.in); //Variables final double METERS_TO_CM = 100; // The constant to convert meters to centimeters final double BSA_CONSTANT = 3600; // The constant to divide by for bsa double bmi; // Body Mass Index double

C++ Won't exit do while loop

随声附和 提交于 2019-12-24 15:09:21
问题 I've just started learning C++. I am currently using Bloodshed Dev C++. dI'm creating a very basic and simple Rock Paper and Scissors Game. Everything in the program is working correctly except for the exit loop. Here is my code: /* FILE INFO File Name: Chapter 3 - Project 1.cpp Author: Richard P. P#: --------- Assignment: Chapter 3 Project 1 */ #include <iostream> using namespace std; int main() { char Player1_choice; char Player2_choice; char keep_going; cout << "Welcome to Rock, Paper,