我如何修复这个问题

dm7nw8vv  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(274)

关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。

两天前关门了。
改进这个问题
我的代码有点工作,但它有一些逻辑问题,如covid数组不工作,我想显示特定的名称有covid。我还在学习java,请忽略我的命名xd

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//variable 
String takers="",hasCovid="";
int length,total,menu;
//Varaible for array
int[] covid = { 3,3,3,3,3,3,3,3};

System.out.println("=================================");
System.out.println("|How Many will take the test|");
length = input.nextInt();
int [] question = new int[length];
System.out.println("=================================");

System.out.println("");
System.out.println("-------------------------------");
System.out.println("Enter [1] for None [2] for quite [3] for severe \n"+question.length+" people will take the test now ");

total = 0;
for (int i = 0; i < question.length; i++){
    System.out.printf("\nEnter  your Name ");  takers=input.next();
    System.out.print("Fever ");
    question[i] = input.nextInt();
    System.out.print("dry cough ");
    question[i] = input.nextInt();
    System.out.print("tiredness ");
    question[i] = input.nextInt();
    System.out.print("aches and pains ");
    question[i] = input.nextInt();
    System.out.print("sore throat ");
    question[i] = input.nextInt();
    System.out.print("diarrhoea ");
    question[i] = input.nextInt();
    System.out.print("headache ");
    question[i] = input.nextInt();
    System.out.print("loss of taste or smell ");
    question[i] = input.nextInt();
    for (int j =0; j < question.length; j++){
        if (question[i] == covid[j]);
            if (question[i] > covid[j]) {
                takers = hasCovid;
            }
}
System.out.println("");
System.out.println("================================");

}
system.out.println(string.format(“|%s has covid |”,takers));

rhfm7lfc

rhfm7lfc1#

你没有具体说明你期望发生什么,或者问题是什么。
但我可以直接看到,有一个循环被“i”索引,然后在循环中,你给它分配了多个值 question[i] = input.nextInt(); . 这是不太可能的工作,因为只有最后一个将被记住。

相关问题