好的,所以我正在尝试转换一些东西。
所以我已经将我的扫描仪转换为字符串,现在我想做的是,获取他们输入的值并将其用作几个 else if 语句的整数。它不会工作!
到目前为止,这是我的代码:
import java.util.Scanner;
public class apples {
public static void main(String args[]) {
Scanner fname = new Scanner(System.in);
Scanner sname = new Scanner(System.in);
Scanner number = new Scanner(System.in);
tuna weight = new tuna();
System.out.println("Enter Your First Name: ");
String fname1 = fname.nextLine();
String fnames = fname1;
System.out.println("Enter Your Last Name: ");
String sname1 = sname.nextLine();
String snames = sname1;
System.out.println("Enter Your Weight (Lbs.) : ");
String num = number.nextLine();
String num1 = num;
System.out.println("Okay " + fname1 + " " + sname1
+ " I can see here that you weigh " + num + "lbs.");
int num2 = num1.parseInt();
if (num1 >= 275)
System.out
.println("You know, you should maybe consider laying off the candy my friend.....");
}
}