Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exc.ConditionalStatementsAdvanced.MoreExercise;
- import java.util.Scanner;
- public class MultiplyBy2 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double max = Integer.MAX_VALUE;
- for (int i = 0; i < max; i++) {
- double num = Double.parseDouble(scan.nextLine());
- if (num > 0) {
- num *= 2;
- System.out.printf("Result: %.2f%n", num);
- } else {
- System.out.println("Negative number!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment