重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
import java.util.ArrayList;
成都创新互联公司成都网站建设按需网站制作,是成都网站开发公司,为石牌坊提供网站建设服务,有成熟的网站定制合作流程,提供网站定制设计服务:原型图制作、网站创意设计、前端HTML5制作、后台程序开发等。成都网站制作热线:13518219792
import java.util.List;
import java.util.Scanner;
public class GradeStatistic {
public static void main(String[] args) {
GradeStatistic gs = new GradeStatistic();
ListMark list = new ArrayListMark();
float sum = 0;
while(true){
Scanner sc = new Scanner(System.in);
System.out.print("Please input student name: ");
String name = sc.nextLine();
if(name.equals("end")){
break;
}
System.out.print("Please input student score: ");
float score = sc.nextFloat();
sum += score;
list.add(gs.new Mark(name, score));
}
float max = list.get(0).getScore();
float min = list.get(0).getScore();
for(Mark mark: list){
if(max mark.getScore()){
max = mark.getScore();
}
if(min mark.getScore()){
min = mark.getScore();
}
}
float average = sum / list.size();
System.out.println("Average is: " + average);
System.out.println("Max is: " + max);
System.out.println("Min is: " + min);
}
private class Mark{
private String name;
private float score;
public Mark(String name, float score){
this.name = name;
this.score = score;
}
public String getName() {
return name;
}
public float getScore() {
return score;
}
}
}
----------------------
Please input student name: Zhang san
Please input student score: 100
Please input student name: Li Si
Please input student score: 91
Please input student name: Ec
Please input student score: 35
Please input student name: ma qi
Please input student score: 67
Please input student name: end
Average is: 73.25
Max is: 100.0
Min is: 35.0
你是青鸟的吧 这我写过 有源码 这里怎么上传压缩包啊
package ghhh;
import java.util.Scanner;
public class DvD {
public static void main(String[] args) {
int state[]=new int[6];
String name[]=new String[6];
int date[]=new int[6];
int count[]=new int [6];
name[0]="权利的游戏";
name[1]="命运之夜";
name[2]="傲慢与偏见";
state[0]=1;
state[1]=0;
state[2]=1;
date[0]=13;
date[1]=0;
date[2]=9;
count[0]=23;
count[1]=23;
count[2]=23;
int n;
// boolean n=false;
do{
System.out.println("欢迎使用迷你DVD管理器");
System.out.println("1.新增DVD");
System.out.println("2.查看DVD");
System.out.println("3.删除DVD");
System.out.println("4.借出DVD");
System.out.println("5.归还DVD");
System.out.println("6.退出DVD");
Scanner input =new Scanner(System.in);
System.out.println("请选择:");
n=input.nextInt();
switch(n){
case 1:
System.out.println("请输入要增加DVD的名称:");
String name1=input.next();
boolean flag=false;
for(int i=0;iname.length;i++){
if(name[i]==null){
name[i]=name1;
flag=true;
break;
}
}
if(flag){
System.out.println("新增DVD"+name1+"成功");
}else{
System.out.println("货架已满!增加失败!");
}
System.out.println("请输入0返回!");
n=input.nextInt();
break;
case 2:
System.out.println("序号\t"+"状态\t"+"名称\t\t"+"借出日期\t"+"借出次数");
for(int i=0;iname.length;i++){
if(name[i]!=null){
String state1 =((state[i]==0)?"可借":"已借");
String date1=((date[i]==0)?"":date[i]+"日");
String count1=count[i]+"次";
System.out.println((i+1)+"\t"+state1+"\t"+name[i]+"\t"+date1+"\t\t"+count1);
}
}
System.out.println("请输入0返回!");
n=input.nextInt();
break;
case 3:
System.out.println("请输入要删除的DVD名称:");
String name2=input.next();
int index=-1;
boolean a=false;
boolean flag1=false;
for(int i=0;iname.length;i++){
if(name2.equals(name[i])state[i]==1){
System.out.println("此DVD已经借出,无法删除");
a=true;
break;
}else if(name2.equals(name[i])state[i]==0){
a=true;
index=i;
flag1=true;
System.out.println("删除成功!");
break;
}
}
if(a==false){
System.out.println("没有找到相同名称的DVD!");
}
if(flag1){
for (int i=index;iname.length;i++){
if(i!=name.length-1){
name[i]=name[i+1];
state[i]=state[i+1];
date[i]=date[i+1];
count[i]=count[i+1];
}
name[name.length-1]=null;
state[name.length-1]=0;
date[name.length-1]=0;
count[name.length-1]=0;
}
}
System.out.println("请输入0返回!");
n=input.nextInt();
break;
case 4:
System.out.println("请输入要借出的DVD:");
String name3=input.next();
boolean a3=false;
boolean b3=false;
for(int i=0;iname.length;i++){
if(name3.equals(name[i]) state[i]==1){
System.out.println("该DVD已经借出");
a3=true;
}else if(name3.equals(name[i]) state[i]==0){
do{
System.out.println("请输入借出的日期:");
int m=input.nextInt();
if(m31||m1){
System.out.println("请重新输入日期:");
b3=true;
}else{
date[i]=m;
state[i]=1;
count[i]+=1;
}
}while(b3==true);
System.out.println("借出成功!");
a3=true;
}
}
if(a3==false){
System.out.println("没有该DVD");
}
System.out.println("请输入0返回!");
n=input.nextInt();
break;
case 5:
System.out.println("请输入要归还的DVD:");
String name5=input.next();
boolean b5=false;
boolean m5=false;
for(int i=0;iname.length;i++){
if(name5.equals(name[i]) state[i]==1){
b5=true;
do{
System.out.println("请输入要归还DVD的日期:(归还日期请输入当月日期 1~31)");
int a5=input.nextInt();
if(a531){
System.out.println("请重新输入日期:");
m5=true;
}else if(a5date[i]){
System.out.println("借出日期是"+date[i]+"日\t输入的日期不能小于借出的日期,请重新输入日期:");
m5=true;
}else{
state[i]=0;
System.out.println("归还成功");
System.out.println("借出日期是:"+date[i]+"归还日期是:"+a5+"日\t租金一天一元:共"+(a5-date[i])+"元");
date[i]=0;
m5=false;
}
}while(m5==true);
}else if (name5.equals(name[i]) state[i]==0){
System.out.println("该DVD未借出,不可归还!");
b5=true;
}
}
if(b5==false){
System.out.println("没有该名称的DVDV");
}
System.out.println("请输入0返回!");
n=input.nextInt();
break;
case 6:
n=1;
System.out.println("程序退出!");
break;
default:
if(n==0){
}else{
System.out.println("输入错误!请重新输入!");
n=0;
}
break;
}
}while(n==0);
System.out.println("谢谢使用!");
}
}
看看有没有问题 好久之前的了
最简单的java代码肯定就是这个了,如下:
public class MyFirstApp
{
public static void main(String[] args)
{
System.out.print("Hello world");
}
}
“hello world”就是应该是所有学java的新手看的第一个代码了。如果是零基础的新手朋友们可以来我们的java实验班试听,有免费的试听课程帮助学习java必备基础知识,有助教老师为零基础的人提供个人学习方案,学习完成后有考评团进行专业测试,帮助测评学员是否适合继续学习java,15天内免费帮助来报名体验实验班的新手快速入门java,更好的学习java!