旅游度假问题练习,烦请老师指正和优化~

来源:4-5 项目作业

Heijyu

2021-08-31 11:22:53

package imooc_redo_exercise;

import java.util.Scanner;

public class Array4_5 {

public static void main(String[] args) {
String[] destinations = new String[5];
int num = (int) (Math.random() * 5);
Scanner sc = new Scanner(System.in);
for (int i = 0; i < destinations.length; i++) {
System.out.println("Please enter NO." + (i + 1) + "tourist place!");
destinations[i] = sc.next();
}
System.out.println("You can go to the following places:");
for (int i = 0; i < destinations.length; i++) {
System.out.print(destinations[i] + " ");

}
System.out.println();
System.out.println("The following one is highly recommended: " + destinations[num]);

}

}

附上运行后截图:

http://img.mukewang.com/climg/612da08809e9a28a17001408.jpg


写回答

1回答

好帮手慕小小

2021-08-31

同学你好,已完成练习,代码实现符合题目要求,很好,继续加油!

祝学习愉快~

0

0 学习 · 9886 问题

查看课程