grach

Multiply by 2

Apr 1st, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Multiplyby2 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         double num = Double.MAX_VALUE;
  7.         while (num>0){
  8.             double num2 = Double.parseDouble(scan.nextLine());
  9.             num++;
  10.             if (num2<0){
  11.                 break;
  12.             }
  13.             System.out.printf("Result: %.2f%n",num2*2);
  14.         }
  15.         System.out.println("Negative number!");
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment