2014-11-30 2 views
0

Может ли кто-нибудь помочь мне с этой проблемой?Информация о методе передачи

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?

ответ

1

Вам нужно сохранить возвращаемое значение PtinSqFt(length,width,height); в переменной, если вы хотите использовать его позже в своем заявлении println.

Так изменить

PtinSqFt(length,width,height); 

к

double newAmount = PtinSqFt(length,width,height); 

и он должен работать.

Смежные вопросы