Advertisement
Guest User

Untitled

a guest
May 6th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.76 KB | None | 0 0
  1. package Exercicios;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class teste {
  6.     public static void main(String[] args) {
  7.  
  8.         System.out.println("Convert Pounds into Kg"); // Note for the user
  9.  
  10.         Scanner input = new Scanner(System.in); // Declaring Scanner
  11.  
  12.         while (true) {
  13.  
  14.             if (input.hasNextDouble()) {
  15.  
  16.                 Double Pounds;
  17.                 Double Resultado;
  18.                 Pounds = input.nextDouble(); // Declare value type used by Scanner
  19.  
  20.                 Resultado = Pounds * 0.4535924;
  21.                 System.out.println(Pounds + "Pounds are " + Resultado + "Kg");
  22.                 System.out.println("Convert Pounds into Kg");
  23.  
  24.             }
  25.  
  26.             else {
  27.                
  28.                 if (input.hasNextLine()) {
  29.  
  30.                     String Erro = input.nextLine();
  31.                     System.out.println("Type a numeric value");
  32.                    
  33.                 }
  34.  
  35.             }
  36.  
  37.         }
  38.  
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement