博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java输出各种学生成绩
阅读量:6858 次
发布时间:2019-06-26

本文共 2059 字,大约阅读时间需要 6 分钟。

1 class stu 2 { 3     public String stuno; 4     public String name; 5     public float math; 6     public float english; 7     public float computer; 8     public float sum; 9     public float average;10     stu(String stuno1,String name1,float math1,float english1,float computer1) //构造函数11     {12         this.stuno = stuno1;13         this.name = name1;14         this.math = math1;15         this.english = english1;16         this.computer = computer1;17     }18     public void sum() //求和方法19     {20         sum = math + english + computer;21         System.out.println("sum = " + sum);22     }23     public void average() //求平均值方法24     {25         average = sum / 3;26         System.out.println("average = " + average);27     }28     public void max() //求最大值方法29     {30         float max;31         if(math > english)32             if(math > computer)33                 max = math;34             else35                 max = computer;36         else37             if(english > computer)38                 max = english;39             else40                 max = computer;41         System.out.println("最高分为:" + max);42     }43     public void min() //求最小值方法44     {45         float min;46         if(math < english)47             if(math < computer)48                 min = math;49             else50                 min = computer;51         else52             if(english < computer)53                 min = english;54             else55                 min = computer;56         System.out.println("最低分为:" + min);57     }58     public void print() //输出方法59     {60         System.out.println("姓名:" + name + " 学号:" + stuno );61         System.out.println("数学成绩:" + math + " 英语成绩:" + english + " 计算机成绩:" + computer);62     }63 }64 class Student65 {66     public static void main(String args[])67     {68         stu stu1 = new stu("2017025425","马云",99,88,77);69         stu1.print();70         stu1.sum();71         stu1.average();72         stu1.max();73         stu1.min();74     }75 }

运行结果:

转载于:https://www.cnblogs.com/YUJIE666/p/6764206.html

你可能感兴趣的文章
【Win10应用开发】自适应磁贴中的分组
查看>>
[20170703]11g增加字段与查询条件的变化
查看>>
mysql配置参数优化
查看>>
微信开放平台 公众号第三方平台开发 教程二 创建公众号第三方平台
查看>>
Swing中弹出对话框的几种方式(转)
查看>>
人工智能时代的工作、学习和生活---《人工智能》阅读笔记
查看>>
linux下使用 du查看某个文件或目录占用磁盘空间的大小
查看>>
将 Intent 序列化,像 Uri 一样传递 Intent!
查看>>
UWP开发入门(十五)——在FlipView中通过手势操作图片
查看>>
Python——set
查看>>
PhxPaxos源码分析——网络
查看>>
SharePoint Error - The SharePoint server was moved to a different location.
查看>>
十款绝bi好用的硬盘数据恢复软件值得拥有简易恢复
查看>>
写给设计师的字偶距调整指南
查看>>
三大优势加身,SDN成广域网优化重要手段
查看>>
苹果iOS 7开发者预览版被黑客成功越狱
查看>>
日常开发常用js日期方法
查看>>
IT气象预报台提醒:企业发展明日多“云”
查看>>
记录一下最近犯下的自以为是的错误
查看>>
云计算的春天:不需再为正版软件买单
查看>>