Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class act8{
- public static void main(String args[]){
- Scanner sc=new Scanner(System.in);
- try{
- double i,n,g,x;
- System.out.println("Enter length in feet and in inches: ");
- i =sc.nextDouble();
- if( i < 0 )
- throw new Exception("Invalid input: enter a positive value");
- g =sc.nextDouble();
- if( g < 0 )
- throw new Exception("Invalid input: enter a positive value");
- n=i*30.48;
- x=g*2.54;
- System.out.println("The equivalent length in inches and in centimeters is: " + "\n" + n + "\n" + x );
- }
- catch(Exception exc3){
- System.out.println(exc3.getMessage());
- }
- //catch(NumberFormatException exc ){
- // System.out.println("Enter a numeric value");
- }
- //catch(InputMismatchException exc1){
- // System.out.println("Enter a numeric value");
- //}
- //catch(NoSuchElementException exc2){
- // System.out.println("Enter a number");
- //}
- finally{
- System.out.println("*********End*********");
- }
- }
- }
Add Comment
Please, Sign In to add comment