我正在写一个客户端数据库。我想根据客户编号了解客户的姓名和家乡。当我输入2号时,我想看到爱丁堡的Arya Stark,当我输入1号时,我想看看伦敦的Jon Snow。为什么我的程序不起作用?如何解决这个问题?package app;import java.util.Scanner;class Person {
String name;
String homeCity;
int customerNumber;}public class Customers {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
String name;
System.out.print ("Give a customer card number: ");
name = input.next();
Person person1 = new Person();
person1.name = "Jon Snow";
person1.homeCity = "London";
person1.customerNumber = 1;
Person person2 = new Person();
person2.name = "Arya Stark";
person2.homeCity = "Edinburgh";
person2.customerNumber = 2;
System.out.println();
}}
添加回答
举报
0/150
提交
取消