Как вы вычитаете конкретное значение для двойного значения? [закрыто]JAVA

Программисты JAVA общаются здесь
Anonymous
Как вы вычитаете конкретное значение для двойного значения? [закрыто]

Сообщение Anonymous »

Для моей программы в Java я вычисляю количество краски, необходимое для комнаты, не рассматривая потолок или пол. Для этого назначения мы должны рассчитать область комнаты, вычитая 15 кв. Футов для каждого окна и 21 для каждой двери - как бы я это форматировал? Имеет ответный оператор, который {область - 15 Windows - 21 двери}; Но это отображается как ошибка, у меня также есть метод для области, не вычитая окна и двери, а также получение среды и метода суммы окна. Также область-это двойные, а окна и двери-это значения int (я не уверен, что это проблема). < /p>
Код-< /p>
import java.util.Scanner;
public class MyProgram
{
public static void main (String[] args)
{
double length, width, height, area, actualarea, paint, gallonsofpaint;
int windows, doors;
length = getlength();
width = getwidth();
height = getheight();
windows = getWindows();
doors = getDoors();
area = computeArea(length, width);
actualarea = computeActualArea(area);

}

//********************************************************

/*
Method: getlength(double)
Description: This method receives a double value for length in feet.
Precondition: One double value for length.
Postcondition: the double value will be received.
*/

public static double getlength()
{
Scanner in = new Scanner(System.in);
double length;
System.out.println("Length:");
length = in.nextDouble();

return length;

}
//********************************************************

/*
Method: getWidth(double)
Description: This method receives a double value for width in feet.
Precondition: One double value for width.
Postcondition: the double value will be received.
*/

public static double getwidth()
{
Scanner in = new Scanner(System.in);
double width;
System.out.println("Width: ");
width = in.nextDouble();

return width;

}
//********************************************************

/*
Method: getHeight(double)
Description: This method receives a double value for height.
Precondition: One double value for height.
Postcondition: the double value will be received.
*/

public static double getheight()
{
Scanner in = new Scanner(System.in);
double height;
System.out.println("height: " );
height = in.nextDouble();

return height;

}
//********************************************************

/*
Method: getWindows(double)
Description: This method receives the number of windows
Precondition: The amount of windows is given.
Postcondition: the amount of windows will be received.
*/

public static int getWindows()
{
Scanner in = new Scanner(System.in);
int windows;
System.out.println("Number of Windows: ");
windows = in.nextInt();

return windows;

}
//********************************************************

/*
Method: getDoors(double)
Description: This method receives the amount of doors.
Precondition: The amount of doors is given.
Postcondition: the number of doors will be received.
*/

public static int getDoors()
{
Scanner in = new Scanner(System.in);
int doors;
System.out.println("Number of Doors: " );
doors = in.nextInt();

return doors;

}
//********************************************************

/*
Method: computeArea(double)
Description: This method calculates the total area of the room.
Precondition: Using two double values of length and width the method will compute the area of the whole room.
Postcondition: the area of the room is calculated wihtout the cieling.
*/

public static double computeArea(double length, double width)
{
return 2*(length*width) + 2*(width*height);
}
//********************************************************

/*
Method: computeActualArea(double)
Description: This method calculates the actual area of the room minus windows and door.
Precondition: Using two int values of windows and doors the method will compute the actual area that needs to be painted.
Postcondition: the actual area of the room that needs to painted is calculated.
*/
public static double computeActualArea(double area)
{
return area - 15*windows - 21*doors;
}
}


Подробнее здесь: https://stackoverflow.com/questions/794 ... uble-value

Вернуться в «JAVA»