No Such Element Exception when trying to input
<p>Alright so this is my first time posting.</p>

<p>I'm trying to create a box using another class that creates a rectangle. But when I try to run, I get to input the values for height and width but right after I try to input depth this error pops up. </p>

<p>Thanks in advance for any help.</p>

<p>Console:</p>

<pre><code>Ange rektangelns bredd: 
10
Ange rektangelns höjd: 
10
En rektangelns med bredden 10 och höjden 10 ger arean 100
Ange rektangelns djup: 
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1371)
at cj222qu.Box.&lt;init&gt;(Box.java:18)
at cj222qu.Steg4_lab02.main(Steg4_lab02.java:7)
</code></pre>

<p>Box class:</p>

<pre><code>import java.util.Scanner;

public class Box extends Rectangle {

private int depth;

public Box() {
    Scanner hej = new Scanner(System.in);

    String dep = null;
    boolean go3 = true;

    while (go3) {
        try {
            System.out.println("Ange rektangelns djup: ");
            dep = hej.next();
            Integer.parseInt(dep);
            go3 = false;
        } catch (NumberFormatException e) {
            System.out.println("Ett fel har inträffat! Ange värdet som ett tal");
            go3 = true;
        }
    }

    //new Box(getWidth(), getHeight(), Integer.parseInt(dep));

    hej.close();
}

public Box(int width, int height, int depth) {

    setDepth(depth);

    System.out.println(toString());
}

public String toString() {
    StringBuilder result = new StringBuilder();

    result.append("En låda med bredden " + getWidth() + ", höjden " + getHeight() + " och djupet " + ".");
    result.append("Lådans volym är " + computeVolume() + ".");
    result.append("Lådans mantelarea är " + computeArea() + ".");
    return result.toString();
}

public int computeVolume() {
    int volume = 0;

    volume = getWidth() * getHeight() * getDepth();

    return volume;
}

public int computeArea() {
    int mantelarea = 0;

    mantelarea = getDepth() * getWidth() * 2 + getDepth() * getHeight() * 2 + getWidth() * getHeight() * 2;

    return mantelarea;
}

public int getDepth()
{
    return depth;
}

public void setDepth(int d)
{
    depth = d;
}
}
</code></pre>

<p>Rectangle class:</p>

<pre><code>import java.util.Scanner;

public class Rectangle {


private int height;
private int width;

public Rectangle(int width, int height)
{
    setHeight(height);
    setWidth(width);

    System.out.println(toString());
}



@Override
public String toString() {
    StringBuilder result = new StringBuilder();

    result.append("En rektangelns med bredden " + width + " och höjden " + height + " ger arean " + computeArea());
    return result.toString();
}



public Rectangle()
{
    Scanner keyboard = new Scanner(System.in);


    String w = null;
    String h = null;
    boolean go1 = true;
    boolean go2 = true;

    while (go1) {
        try {
            System.out.println("Ange rektangelns bredd: ");
            w = keyboard.next();
            Integer.parseInt(w);
            go1 = false;
        } catch (NumberFormatException e) {
            System.out.println("Ett fel har inträffat! Ange värdet som ett tal");
            go1 = true;
        }

    } 

    while (go2) {
        try {
            System.out.println("Ange rektangelns höjd: ");
            h = keyboard.next();
            Integer.parseInt(h);
            go2 = false;
        } catch (NumberFormatException e) {
                System.out.println("Ett fel har inträffat! Ange värdet som ett tal");
                go2 = true;
        }
    }

    new Rectangle(Integer.parseInt(w), Integer.parseInt(h));


    keyboard.close();
}

public int computeArea()
{
    int area = 0;

    area = getHeight() * getWidth();

    return area;
}

public int getHeight()
{
    return height;
}

public int getWidth()
{
    return width;
}

public void setHeight(int h)
{
    height = h;
}

public void setWidth(int w)
{
    width = w;
}
}
</code></pre>

<p>Main:</p>

<pre><code>public class Steg4_lab02 {

public static void main(String[] args) {

    new Box();

}

}
</code></pre>