我的代码:
import java.io.*;
public class compute_volume
{
public static void main(String args[])throws IOException{
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(reader);
boolean answer;
double radius,height;
final double pi = 3.14159;
do{System.out.println("Enter the radius,press enter and then enter the height");
String t = input.readLine();
radius = Integer.parseInt(t);
t = input.readLine();
height = Integer.parseInt(t);
System.out.println("The volume of a cylinder with radius " + radius + " and height " + height + " is " + (pi*pi*height) + "\n Thanks for using my cylinder volume calculator.Enter \"yes\" to use again or \"no\" to stop.");
t = input.readLine();
System.out.println(t);
if ( t == "yes"){
answer = true;
}else{
answer= false;
}
}while(answer);
}
}
问题:
用户输入yes
但计算器没有重新启动。
解决方案:
那是我不知道的,希望通过在这里发布来知道。