Advertisement
kalin729

Umnojenie po 2

Jun 10th, 2022
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PosMain {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double num = Double.parseDouble(scanner.nextLine()); //chislo i vuvejdane
  8.  
  9.         while(num>0){ // proverqva dali chisloto e positivno
  10.             System.out.printf("%.2f", (num*2));
  11.             num = Double.parseDouble(scanner.nextLine()); //otnovo vuvejdash chislo
  12.         }
  13.         System.out.println("Negative number!"); //sled kato e namerilo otricatelno - izpisva
  14.     }
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement