How to get conditional input in java? -
i want enter 2 numbers csv , cr. condition that: if csv positive, cr can positive or negative. if csv negative, cr cannot positive how can this?
scanner scanner = new scanner(system.in); system.out.print("csv: "); double csv = scanner.nextdouble(); system.out.print("cr: "); double cr = scanner.nextdouble(); if (csv < 0.0) { while (cr > 0.0) { system.out.println("cr cannot positive since csv negative."); system.out.print("cr: "); cr = scanner.nextdouble(); } }
Comments
Post a Comment