Posts

Showing posts with the label if-statement

How to create if statement that is always checked in Python

Image
Clash Royale CLAN TAG #URR8PPP How to create if statement that is always checked in Python Can you create if statement that is always checked in python? Like: You can enter a command anytime during the execution of the code but you create if statement only once, not after each action. Can you show an example of what are you trying to achieve? Basically you should provide Minimal, Complete, and Verifiable example. – zipa 5 secs ago By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Why is an if statement working but not a switch statement

Image
Clash Royale CLAN TAG #URR8PPP Why is an if statement working but not a switch statement Title is terrible, but I wasn't too sure what to put. I'm trying to create Switch Statement using the char index of a string and an Enum using this wrapper to get the value of the selected enum from a Description, it pretty much allows you to store a string to an enum value. Here is my if statement Switch Statement if statement if (msgComingFromFoo[1] == Convert.ToChar(Message.Code.FOO_TRIGGER_SIGNAL.EnumDescriptionToString())) { //foo } and here is my Switch statement Switch statement switch (msgComingFromFoo[1]) { case Convert.ToChar(Message.Code.FOO_TRIGGER_SIGNAL.EnumDescriptionToString()): break; } Why is it accepting the if statement and not the switch statement ? I tried converting it to a char since I'm selected an index from a string, but unfortunately i didn't work. if statement switch statement Update: Here is the Message.Code Enum Message.Code public ...

Input Value Out of Range

Image
Clash Royale CLAN TAG #URR8PPP Input Value Out of Range Wonder with the request. "If the score is out of Range, print an Error". How to get the condition out of range if the following variables are >= 0.9(A) and < 0.6(F). Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table: Score Grade >= 0.9 A >= 0.8 B >= 0.7 C >= 0.6 D < 0.6 F If the user enters a value out of range, print a suitable error message and exit. For the test, enter a score of 0.85. What have you tried so far? – Luca Cappelletti 9 mins ago so far the code I created was working for keying score, however I still don't get how to create the condition "out of range", could you help...

How do I use != in java strings [closed]

Image
Clash Royale CLAN TAG #URR8PPP How do I use != in java strings [closed] My code has a validator which states that if "d" is entered display an error message. If "c", "s", or "v" are entered do the calculation. How can I construct gender.equalsIgonreCase to include all words and letters that are not "c", "s", or "v"? gender.equalsIgonreCase Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. All ASCII letters but c , s , v ? gender.matches("(?i)[a-z&&[^csv]]") ? – Wiktor Stribiżew Sep 22 '16 at 21:18 ...

Barcode scanner app parses barcode string to URL

Image
Clash Royale CLAN TAG #URR8PPP Barcode scanner app parses barcode string to URL I'm trying to build an app for learning purposes. It's a simple QR code and Barcode scanner app with a two flows: I have achieved goal number one with the if statement public void handleResult(Result result) { final String myResult = result.getText(); Log.d("QRCodeScanner", result.getText()); Log.d("QRCodeScanner", result.getBarcodeFormat().toString()); if(Patterns.WEB_URL.matcher(result.getText()).matches()) { // Open URL Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(result.getText())); startActivity(browserIntent); } } My challenge is now with goal number to which I just can't get to compile. I was thinking using an else statement and parse Uri with something like google.com + the string. The expected result is that if the scanner returns and value which is not a URL pattern open the browser go to google and sea...

Python seems to ignore “elif” part

Python seems to ignore “elif” part I've decided to make a simple calculator. It asks the user for two numbers, what does he want to do with them, and then asks how many numbers there actually is. I've come up with nothing better than do one if -statement when there are 2 numbers, one elif when there are 3 of them, and one else part, when it just asks you for more numbers until you type "end" and then calculates. if elif else The thing is, it seems to completely ignore elif part, it doesn't even asks the question there. Everything else works just fine. And i just can't see what's wrong there. elif Here's a part of my code, please, suggest, what is wrong here. while True: try: x = float(input("Enter your numbern")) y = float(input("Enter another numbern")) operator = input("Enter the operationn") check = float(input("How many numbers are there?n")) if check == 2: ...

How would I modify this fgetcsv to check multiple columns (not just one!)

How would I modify this fgetcsv to check multiple columns (not just one!) I have a working script below which checks a column (1) for something and if found, looks at the adjacent column (0) and does some stuff. (i've excluded stuff above the important code but it loops round every file in a directory as $thisGame or thisGameNoExtension which is the same just with no file extension! $thisGame thisGameNoExtension $csvFile = fopen("ManualRegionDupes.csv", "r"); while ($csvRows = fgetcsv($csvFile)) { if ($csvRows[1] == $thisGameNoExtension) { $primaryGame = $csvRows[0]; $fileExtension = pathinfo($thisGame, PATHINFO_EXTENSION); $fileCheck = trim(shell_exec("ls -1 " . escapeshellarg($primaryGame) . "." . escapeshellarg($fileExtension) . " 2>/dev/null")); if ($fileCheck) { echo "33[00;33m is on the Manual Region Dupes list and primary version detected. Moved to Removed ...