Calculating Volume

Sort by

recency

|

113 Discussions

|

  • + 0 comments

    What are "kackos"? One of the test cases was wrong. I clicked on it to see the test case input and expected results. The response asked if I am willing to pay "5 hackos"

    I responded: "No" because I do not understand what "hackos" mean.

  • + 0 comments

    "Required methods" should be listed in the problem description.

  • + 0 comments

    My code is not working. Its not reading the input properly can any one help me on this...

    lass Calculate{

    final Display output =new  Display();
    
    public int get_int_val() throws IOException {
        int number =0;
        Scanner sc=new Scanner(System.in);
        if(sc.hasNextInt()){
            number = sc.nextInt();
        }else{
            sc.close();
        }
    
    
    return number;
    }
    
    public double get_double_val() throws IOException{
        double number =0;
        Scanner sc=new Scanner(System.in);
        if(sc.hasNextDouble()){
            number = sc.nextDouble();
        }
    
        return number;
    }
    
    public static Calculate do_calc(){
    
        return new Calculate();
    }
    
    public double get_volume(int a){
    
        if(a <= 0){
            throw new NumberFormatException("All the values must be positive");
        }else{
            DecimalFormat df = new DecimalFormat("#.000");
            return Double.parseDouble(df.format(a * a * a));
    
        }
    
    }
    
    public double get_volume(int l, int b, int h){
    
        if(l <= 0 || b <= 0 || h <= 0){
            throw new NumberFormatException("All the values must be positive");
        }else{
            DecimalFormat df = new DecimalFormat("#.000");
            return Double.parseDouble(df.format(l * b * h));
    
        }
    
    }
    
    public double get_volume(double r){
    
    
    
        if(r <= 0){
            throw new NumberFormatException("All the values must be positive");
        }else{
            DecimalFormat df = new DecimalFormat("#.000");
            return Double.parseDouble(df.format((2/3)*3.14159265*(r*r*r)));
    
        }
    
    }
    
    
    public double get_volume(double r, double h){
    
    
    
        if(r <= 0 || h <=0 ){
            throw new NumberFormatException("All the values must be positive");
        }else{
            DecimalFormat df = new DecimalFormat("#.000");
            return Double.parseDouble(df.format(3.14159265*(r * r * h)));
    
        }
    
    }
    

    }

    class Display{

    public void display(double volume){
    
        System.out.println(volume);
    
    }
    

    }

  • + 0 comments

    What exactly is this exercise meant to be teaching?

    The problem is contrived and you and end up with convoluted rubbish that is just staggeringly bad code. If I were reviewing this it would be sent straight back to the engineer.

    I was beginning to have my doubts about how useful HackerRank was and this just confirms my suspicions.

    If you want to learn how to write good code then look elsewhere.

  • + 1 comment

    That problem was seriously more complicated than it needed to be.