我正在尝试制作一个程序,告诉他们是否可以乘坐过山车.只要输入有效,它就可以工作,但我希望它显示一条消息,说明如果用户输入其他内容则重试.我尝试使用try和catch,但它仍然显示错误(NumberFormat异常).任何帮助表示赞赏,谢谢.
private void btnCalculateActionPerformed(java.awt.event.ActionEvent evt) {
String strHeight, strBackTrouble, strHeartTrouble;
int intHeight;
strHeight = txtInputHeight.getText();
strBackTrouble = txtInputBackTrouble.getText();
strHeartTrouble = txtInputHeartTrouble.getText();
intHeight = Integer.parseInt(strHeight);
try {
if (intHeight < 188 || intHeight > 122) {
if (strBackTrouble.equals("N") || strBackTrouble.equals("n") || strHeartTrouble.equals("N") || strHeartTrouble.equals("n")) {
txtOutput.setText("It is OK for you to ride this roller coaster. Have fun!");
}
} else if (strBackTrouble.equals("Y") || strBackTrouble.equals("y") || strHeartTrouble.equals("Y") || strHeartTrouble.equals("y")) {
txtOutput.setText("Sorry, it is not safe for you to ride this rollercoaster");
} …Run Code Online (Sandbox Code Playgroud) 我试图让图像在背景中显示为一个统一的图像.我究竟做错了什么?谢谢.
.content{
background-color: gray;
top: 0;
position: relative;
background-size: cover;
left: 0;
right: 0;
bottom: 0;
background:url(cropped.jpg);
background-repeat: no repeat;
}
Run Code Online (Sandbox Code Playgroud)