Guest User

Untitled

a guest
Apr 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class act8{
  4. public static void main(String args[]){
  5. Scanner sc=new Scanner(System.in);
  6. try{
  7. double i,n,g,x;
  8. System.out.println("Enter length in feet and in inches: ");
  9. i =sc.nextDouble();
  10. if( i < 0 )
  11. throw new Exception("Invalid input: enter a positive value");
  12. g =sc.nextDouble();
  13. if( g < 0 )
  14. throw new Exception("Invalid input: enter a positive value");
  15. n=i*30.48;
  16. x=g*2.54;
  17. System.out.println("The equivalent length in inches and in centimeters is: " + "\n" + n + "\n" + x );
  18. }
  19. catch(Exception exc3){
  20. System.out.println(exc3.getMessage());
  21. }
  22. //catch(NumberFormatException exc ){
  23. // System.out.println("Enter a numeric value");
  24. }
  25. //catch(InputMismatchException exc1){
  26. // System.out.println("Enter a numeric value");
  27. //}
  28. //catch(NoSuchElementException exc2){
  29. // System.out.println("Enter a number");
  30. //}
  31. finally{
  32. System.out.println("*********End*********");
  33. }
  34.  
  35.  
  36. }
  37. }
Add Comment
Please, Sign In to add comment