【发布时间】:2020-02-06 06:37:59
【问题描述】:
我什至不知道如何正确地提出这个问题,但我被分配了一个任务,要求我向用户询问输入(在这种情况下,它是一些绵羊)。然后,在他们输入一个数字(比如 5)后,我应该要求用户根据他们输入的整数分配一个 x 和 y 坐标值。我目前的理论是将原始数字存储在一个数组中,然后根据它们的值以某种方式询问用户有多少坐标(或一组 2 个数字)。
我真的不知道如何开始,但到目前为止我会附上我的代码。
private int x, y;
public static void main(String[] args) {
Scanner sheepScanner = new Scanner(System.in); //Allows for user input
System.out.println("Enter a number of Sheep"); //Asks user for input
int numSheep = sheepScanner.nextInt(); //reads in number of sheep and stores it in variable numSheep
int totalSheep[] = new int[numSheep]; //creates an array called totalSheep based on numSheep
//System.out.println(totalSheep);
for (int i = 1; i < totalSheep.length; i++) {
totalSheep[i]=Integer.parseInt(); //literally no idea what's going here
【问题讨论】: