【发布时间】:2014-09-28 02:36:13
【问题描述】:
在我下面的代码中double getAirSpeeddouble calcPatternwidth 和double calcPatternLength 没有被正确初始化,为什么?
/**
* holding patterns
* assignment 1
* question 2
**/
import java.util.Scanner;
public class StockiColeA1Q2 {
public static void main(String []args) {
Scanner keyboard = new Scanner(System.in);
double getAirSpeed ;
double calcPatternWidth;
double calcPatternLength;
System.out.println("That speed is " + getAirSpeed +
"\nHolding pattern width: " + calcPatternWidth +
"kms\nHolding pattern length: " + calcPatternLength + "kms");
}//main
public static double getAirSpeed() {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the speed in Knots: ");
double knots = keyboard.nextDouble(); //knots given by user
return knots*1.852;
}//get air speed
public static double calcPatternWidth(double knots) {
return (knots/60*Math.PI)*2;
}//patern width
public static double calcPatternLength(double knots) {
return knots/60 + (knots/60*Math.PI)*2;
}//pattern width
}//class
【问题讨论】:
-
有什么问题?预期的输出是多少?你得到什么,有什么错误吗?请在问题 BODY(不是标题)中澄清它。此外,为您的问题添加标签,特别是代码的语言。
-
你声明它们,然后不要对它们做任何事情。所以这就是你的答案:如果你想要 in 他们的任何东西,你必须首先让你的代码做到这一点。