【发布时间】:2021-08-22 21:36:26
【问题描述】:
我被要求写一个作业,我必须要求用户输入一个至少为 7 的数字,该数字确定他们必须输入的双精度数,对于第一个输入,我必须使用 while 循环然后要检查双十进制数,我必须使用 for 循环,这样我就可以要求用户输入这 7 个双精度数。最后,我必须显示总共输入了多少个数字,其中哪些数字是最小的负奇数。提前谢谢!
目前我的代码如下所示:
public class D6_4 {
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
System.out.println("Type a number that is at least 7");
int number = sc.nextInt();
int count = 0;
int condition = 0;
while(number<7){
System.out.println("Type a number that fulfills the condition at least 7");
number = sc.nextInt();
}
sc.nextLine();
double decimalNumber = 0;
for(int i =0; i<number; i++){
System.out.println("Type some decimal numbers");
decimalNumber = sc.nextDouble();
count++;
/*here i need to create the condition for the code to check
which of the numbers is the smallest odd negative number*/
}
}
}
【问题讨论】:
标签: java string methods contains extends