java如何使用if else存储在数组中

问题描述 投票:0回答:1

我有一段代码,我根据 Android 应用程序中的某些条件设置文本。这是一个片段:

如果(第五< 100 && fifth >= 96.5)

        fivet.setText("1.00");
    

else if (第五个 < 97 && fifth >= 92.5) Fivet.setText("1.25");

else if (第五 < 93 && fifth >= 88.5) Fivet.setText("1.50");

else if (第五 < 89 && fifth >= 84.5) Fivet.setText(“1.75”);

else if (第五 < 85 && fifth >= 81.5) Fivet.setText("2.00");

else if (第五 < 82 && fifth >= 78.5) Fivet.setText("2.25");

else if (第五 < 79 && fifth >= 75.5) Fivet.setText("2.50");

else if (第五 < 76 && fifth >= 72.5) Fivet.setText("2.75");

else if (第五 < 73 && fifth >= 69.5) Fivet.setText("3.00");

else if (第五个 < 70 && fifth >= 0)

        fivet.setText("5.00");
    

否则

        fivet.setText("NE");
    

我不想使用“setText”直接设置文本,而是想将这些输出值存储在数组中。我该如何修改这段代码来实现这一目标?

谢谢!

java arrays oop conditional-statements
1个回答
-2
投票

我不明白,你做了这个 if/else 语句,文本中的值取决于语句的结果。 为什么要将该值保存在数组中?

© www.soinside.com 2019 - 2024. All rights reserved.