云南大学JAVA程序设计实验三
指标等级 A B C D 功能完整 程序质量 按时检查 提问回答 检查时间 总评成绩 云南大学软件学院 实 验 报 告 序 号: 实验老师: 陆歌皓 课程名称: JAVA程序设计实验 实验名称: JAVA开发环境 学 号: 20111120279 姓 名: 李张昱 实验三 Fundamental programming structures in java: Control Flow, Big Numbers, Arrays and Vectors 一.实验目的 练习java基本编程结构,包括字符串、输入输出控制流。 二.实验内容(算法、程序、步骤和方法) 任务一. Write a Java program called AverageNumbers2.java that calculates the average of numbers 1 to 50 using the for loop. Do it again using the while loop. Output: average of numbers is 25.5 根据实验要求写了以下程序: public class AverageNumbers2{ public static void main(String[] args){ float sum=0; for(int i=1;i<=50;i++) sum+=i; float average=sum/50; System.out.println(“average of numbers 1 to 50 is “+average); } } 任务二. Write a Java program called Parms.java that accepts 3 arguments in the main using an array. Iterate through the array looking for your name using a for loop. Display the message “The name was found“ if your name is found. For example, using the following command Java Parms I am Michael Output: The name Michael was found. 根据实验要求写了以下程序: import java.util.Scanner; public class Parms { public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.println(“you can 3 number of name at will“); int a=3; String[] name=new String[a]; for(int i=0;i