Category "if-statement"

Python - Convert a roman numeral to an integer

I've tried the following Python 3 code that transform from Roman to Integer. The code is working fine at a glance. But there are certain problem happened when

Error: 'else' without 'if'

Getting an else without if statement: import java.util.Scanner; public class LazyDaysCamp { public static void main (String[] args) { int temp

Idiomatic way to check for non-zero

When I wish to check if a value is 0 in C, how is it idiomatically done? if (!num) if (num == 0)

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

I have a little problem with my if(isset($_POST['submit'])) code. What I want is some echos and a table to not appear when the script is open but I do want it t

Open new page using if else statement to check to see if an html form element is equal to a certain word

How do I open new page using an if else statement to check to see if an html form element is equal to a certain word or phrase. Basically, I have a form and if

Assignment in an if statement

I have a class Animal, and its subclass Dog. I often find myself coding the following lines: if (animal is Dog) { Dog dog = animal as Dog; dog.Name

Multiple If-else or enum - which one is preferable and why? [closed]

Here is the original code: public class FruitGrower { public void growAFruit(String type) { if ("wtrmln".equals(type)) {

If statement executing all conditions

This may actually be a silly question but I am wondering if it is possible to have an if statement executing all conditions. I explain: if (methodA() &&

How is if/while condition evaluated when we use assignments instead of comparison?

I discovered this surprising thing while learning OCA/OCP for Java. Below is the first piece of code of which the if(test condition) part surprises me. public

Evaluate command line argument as boolean expression

I'm trying to take a string, passed as an argument, and evaluate it as a boolean expression in an if conditional statement. For example, the user invokes MyPro

Is an "if(...) return ...;" without "else" considered good style? [closed]

This code: if( someCondition ) return doSomething(); return doSomethingElse(); versus this code: if( someCondition ) return doSom