Java 传递方法信息
有人能帮我解决这个问题吗Java 传递方法信息,java,Java,有人能帮我解决这个问题吗 import java.util.*; public class PaintCalculator { public static void main(String[] args) { double length; double width; double height; S
import java.util.*;
public class PaintCalculator
{
public static void main(String[] args)
{
double length;
double width;
double height;
Scanner input = new Scanner(System.in);
System.out.print("Enter the length in feet: ");
length = input.nextDouble();
System.out.print("Enter the width in feet: ");
width = input.nextDouble();
System.out.print("Enter the height in feet: ");
height = input.nextDouble();
System.out.println();
PtinSqFt(length,width,height);
System.out.println("The Cost of a " + length + "- by " + width + "-foot room with a " + height + "-foot ceilings is " + newAmount + "$");
}
public static double PtinSqFt(double v1, double v2, double v3)
{
double GoP = v1*v2*v3;
double newAmount;
newAmount = GallonsOfPaint(GoP)*32;
System.out.println("The wall area for the room is " + GoP + " Square Feet!");
System.out.println("You will need " + GallonsOfPaint(GoP) + " gallons of paint!");
System.out.println("The Cost of a " + v1 + "- by " + v2 + "-foot room with a " + v3 + "- foot ceilings is " + newAmount + "$");
return newAmount;
}
public static double GallonsOfPaint(double GoP)
{
final double SQFT_OF_RM = 350;
double newgallons = (GoP/SQFT_OF_RM);
return newgallons;
}
}
当我试图从我的PtinSqFt方法中提取返回信息时,它不会编译?您需要存储
PtinSqFt(长度、宽度、高度)的返回值如果以后要在println
语句中使用变量中的code>
所以改变这个
PtinSqFt(length,width,height);
到
它应该会起作用
double newAmount = PtinSqFt(length,width,height);