一、编程Ex3_1.java:给定字符串“The past is gone and static. Nothing we can do willchange it. Thefuture is before us and dynamic. Everything we do will affect it.”,请统计指定字符(使用Scanner输入一个字符)出现的频率(次数)。【注意是用Scanner输入一个字符】
import java.util.Scanner
public class Ex3_1{
public static void main(String[] args){
System.out.println("请输入一个字母")
Scanner sc = new Scanner(System.in);
//中间怎么写
char c=sc.next().charAt(0);//输入单个字符
//要写循环
}
}
二 编程Ex3_4.java:随即产生20个0至99的整数存储于一个一维数组中,然后求出该组整数中的最大数,最后输出该组整数及最大值。
要用到(int)Math.random()*99
int max=a[0]
for(int i=1;i<a.length;i++){ }
跪谢!~~~~~~~~~~~~~
同意楼上,我也是新手,基础的自己多写写有好处~,代码如下,仅供参考
import java.util.Scanner;