So this situation is a bit frustrating for me because my online teacher prefers us to just learn the lessons online by ourselves independently and everywhere I have looked I still cannot find out how to use no-args completely
The following is the program I am creating, however as I know it I cannot run it without a main, but whenever I enter a main it does not run the no-args construct and I just in general have no idea where I am messing up.
import java.util.Scanner;
public class Week07_Assignment {
Scanner input = new Scanner(System.in);
private double height = 1;
private double width=1;
private double h;
private double w;
public void createrectangle(){
System.out.println("Give me both the height and width of this rectangle");
height = heightgetter(height);
width = heightgetter(width);
area(height, width);
perimeter(height, width);
}
public double heightgetter(double a){
a = input.nextDouble();
return a;
}
public double widthgetter(double a){
a = input.nextDouble();
return a;
}
public void area(double a, double b){
double area = a * b;
System.out.println("This is the area: " +area);
}
public void perimeter(double a, double b){
double perimeter = 2 * (a + b);
System.out.println("This is the area: " +perimeter);
}
}
main
method is a static method, no constructor is called. If you need to call the default constructor, you have to do it explicitly. And if your professor refuses to explain things his students didn't understand, well... Not a good professor IMO.