user-input

C#- Getting error when trying to parse user input to int

二次信任 提交于 2020-01-15 10:42:09
问题 I am new to c#, and I can't figure out why I keep getting a 'FormatException was unhandled' error when I run this method: public void bet() { int betAmount; Console.WriteLine("How much would you like to bet?"); betAmount = int.Parse(Console.ReadLine()); Console.WriteLine(_chips - betAmount); } The program does not stop to wait for user input, and I don't know why this is? What can I do to get the program to wait for the user's input in this method? **I was running the program on Microsoft

user input in R (Rscript and Widows command prompt)

[亡魂溺海] 提交于 2020-01-12 04:00:08
问题 I am trying to figure out, how can i run an r script, using Rscript in windows command prompt and ask for user input. So far, i have found answers on how do ask for user input in R's interactive shell. Any effort in doing the same with readline() or scan() has failed. example: I have a polynomial y=cX where X can take more than one values X1 , X2 , X3 and so on. C variable is know, so what i need in order to calculate the value of y is to ask the user for the Xi values and store them

How to make user input relate to a variable?

血红的双手。 提交于 2020-01-11 13:15:50
问题 I don't know how to phrase this question precisely, but this is what I want to achieve (I am implementing the Towers of Hanoi illustration using stacks: This is inside the main() function: System.out.println("Type the source pole number and the destination pole number"); int a = reader.nextInt(); int b = reader.nextInt(); boolean move = moveDics(a, b); These are the stacks which represent the 3 poles: Stack<Integer> pole1 = new Stack<Integer>(); Stack<Integer> pole2 = new Stack<Integer>();

How to take n numbers as input in single line in Python?

老子叫甜甜 提交于 2020-01-11 10:08:21
问题 like in c++ how can I ask user input upto a range Below is the code to take user input in c++ #include<iostream> using namespace std; int main() { int array[50]; cin>>n; //ask a list for(i = 0; i<n; i++){ cin>>array[i]; } } how can I ask user input like above in python3? (I dont want to take the inputs in different lines) 回答1: There are various methods to do this. User can enter multiple inputs in single line separated by a white space. Let's say I want user to enter 5 numbers as 1 2 3 4 5

In a bash script, how do I sanitize user input?

二次信任 提交于 2020-01-10 07:26:07
问题 I'm looking for the best way to take a simple input: echo -n "Enter a string here: " read -e STRING and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores. Does order matter? Is tr the best / only way to go about this? 回答1: As dj_segfault points out, the shell can do most of this for you. Looks like you'll have to fall back on something external for lower-casing the string, though. For this you have many options, like the perl one-liners

Python getting user input errors

北城余情 提交于 2020-01-10 06:03:02
问题 I have a simple program that prompts user to enter number between 1-9 and if the number has been entered previously it will ask the user to enter another number. The user has 10 tries or attempts. This is only part of what I wanted to do but I am having problems passing the parameter from the getNum method to the method that calls it. If I enter the number between 1-9, it has no problem. The problem starts when I entered the number previously entered and the prompts ask for another number.

Python getting user input errors

瘦欲@ 提交于 2020-01-10 06:02:08
问题 I have a simple program that prompts user to enter number between 1-9 and if the number has been entered previously it will ask the user to enter another number. The user has 10 tries or attempts. This is only part of what I wanted to do but I am having problems passing the parameter from the getNum method to the method that calls it. If I enter the number between 1-9, it has no problem. The problem starts when I entered the number previously entered and the prompts ask for another number.

excel or excel VBA: how can I let user click on a cell and use it as a match result to an existing cell

寵の児 提交于 2020-01-07 03:06:25
问题 Wanted Attached is a snip picture of what I want to do. I have one column that lists all the options, and on the second column some items. For each item I want the user to physically select a cell and I can then use that selection as the match to the item. For example if the use click on "user1" then I need to populate cell D4 with text "user1". How can I achieve this? Thanks! 回答1: On the code for the worksheet from which you want to use the selection: Private Sub Worksheet_SelectionChange

Creating file loop

左心房为你撑大大i 提交于 2020-01-07 02:01:20
问题 How can I ask the user for a file name and if it already exists, ask the user if they want to overwrite it or not, and obey their request. If the file does not exist, a new file (with the selected name) should be created. From some research on both the Python website and Stack Overflow, I've come up with this code try: with open(input("Please enter a suitable file name")) as file: print("This filename already exists") except IOError: my_file = open("output.txt", "r+") But this will not run in

User input verification upon certain condition

谁都会走 提交于 2020-01-06 12:48:06
问题 I am lettings users enter their Social Security number (SSN). My system checks for SSNs in use. If the SSN is in use it says that the SSN is in use and check info. However, they are not required to enter it. How do i write a script that will check if they entered it and then verify it and if they don't enter it and they NOne or n/a then let the form process. Update on question: I have a certain field value that the php checks for in the DB. If the value exists, it will not let a form process