-5
내 방법에 문제가 있습니다. 그것은 항상 0.0의 값을 반환하므로 문 열림을 계산하지 않는 것 같습니다. 입력 된 길이와 높이를 기준으로 계산해야합니다. 감사합니다문 공간을 계산하는 방법이 왜 아닌가요?
package Hw;
import java.util.Scanner;
public class HouseReno3 {
public static void main(String[] args) {
// Initialize and Declare Variables
double ceramictile = 4.00;
double hardwood = 3.00;
double carpet = 2.00;
double linoleumtile = 1.00;
// Initialize Variables
int floortype;
int budget;
double length;
double height;
double width;
double ld = 0;
double hd = 0;
double lw1;
double hw1;
double lw2;
double hw2;
double lb;
double hb;
double wb;
double door = 0;
double window = 0;
double bookshelf = 0;
double doorspace = 0;
doorspace = itemd (door, ld, hd, doorspace);
// double costp;
// double costf;
// Initialize Scanner
Scanner keyboard = new Scanner (System.in);
System.out.println("Enter Number Of Doors");
door = keyboard.nextDouble();
for(int doors = 0; doors < door; doors++)
{
System.out.println("What is the length of the door (in feet)? ");
ld = keyboard.nextDouble();
System.out.println("What is the height of the door (in feet)? ");
hd = keyboard.nextDouble();
System.out.println("Doorspace is: " + doorspace);
}
System.out.println("Enter Number Of Windows");
window = keyboard.nextDouble();
for(int windows = 0; windows < window; windows++)
{
System.out.println("What is the length of the window (in feet)? ");
lw1 = keyboard.nextDouble();
System.out.println("What is the height of the window (in feet)? ");
hw1 = keyboard.nextDouble();
}
System.out.println("Enter Number Of Bookshelves");
bookshelf = keyboard.nextDouble();
for(int bookshelves = 0; bookshelves < bookshelf; bookshelves++)
{
System.out.println("What is the length of the bookcase (in feet)? ");
lb = keyboard.nextDouble();
System.out.println("What is the height of the bookcase (in feet)? ");
hb = keyboard.nextDouble();
System.out.println("What is the width of the bookcase (in feet)? ");
wb = keyboard.nextDouble();
}
}
private static int itemd(double door, double ld, double hd, double doorspace) {
doorspace = ld *hd;
return (int) doorspace;
}
}
에 선
을 변경하기에 충분 것입니까? – Berger
그랬지만 출력은 여전히 0.0 –
'System.out.println ("Doorspace is :"+ itemd (door, ld, hd, doorspace)); 대신'System.out.println "Doorspace는"+ 문 공간); '입니다. – Berger