Detect the Email Addresses

  • + 1 comment

    Change your code like the below.

    class Calculate {
    public static Scanner sc =new Scanner(System.in);
    ~~~~
    public void checkString(String s){
    
            if (s.startsWith("-")|| Double.valueOf(s)<=0)
                throw new NumberFormatException("All the values must be positive");
    
    }
    
    ~~~~~
        public class Output {
        public void display(double volume) {
            ~~~~~
            if(Double.valueOf(s)>0)
                System.out.println(s);
        }
    }