Rocco_g Rocco_g - 1 month ago 17
Java Question

Square footage program

I need to create a program in Java that calculates the square footage of a house with 4 rooms. I unsure how to start this as I am new to java. I can choose the dimensions of the rooms so it will not require user input at all. I understand I can use length * width to get the room square footage and than add all four rooms to out.println the house square footage. I am just unsure how to set this all up.

public class sqfoot {
public static void main(String args[]){
double length, width;
room1
}

}


this is all I have so far. Can anyone help me please?

Answer

Complete your code with some thing like this :

import java.util.Scanner;

public static void main(String[] args){

Scanner scan = new Scanner(System.in);

double len = 0;
double wid = 0; 

System.out.print("Enter the length in feet:(##.##) ");

   len = scan.nextDouble();

System.out.print("\nEnter the width in feet: (##.##) ");

   wid = scan.nextDouble();

System.out.print("\n"+"The area is "+wid*len+" square feet.");

}