HW6.1
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of students: "); int numberOfStudents = input.nextInt(); System.out.print("Enter " + numberOfStudents + " scores: "); int[] score = new int[numberOfStudents]; int best = 0; for(int i = 0 ; i < numberOfStudents; i++) { score[i] = input.nextInt(); if(score[i] >= best) best = score[i]; } input.close(); for(int i = 0 ; i < numberOfStudents; i++) System.out.println("Student " + i + " score is " + score[i] + " and grade is " + getGrade(score[i], best)); } public static char getGrade(int score, int max) { if(score >= max - 10) return 'A'; else if(score >= max - 20) return 'B'; else if(score >= max - 30) return 'C'; else if(score >= max - 40) return 'D'; else return 'F'; } }
HW6.1的更多相关文章
- HW6.30
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.29
public class Solution { public static void main(String[] args) { int count = 0; int[] card = new int ...
- HW6.28
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.27
import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(S ...
- HW6.26
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.24
public class Solution { public static void main(String[] args) { int count = 0; int color; int numbe ...
- HW6.23
public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...
- HW6.22
import java.util.Arrays; public class Solution { public static void main(String[] args) { int[][] ch ...
- HW6.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- java去掉List中的重复值代码
1. list中为字符串的情况,代码如下: public static void main(String[] args) { List<String> li = new ArrayList ...
- Makefile教程
Makefile学习教程: 跟我一起写 Makefile 0 Makefile概述 0.1 关于程序的编译和链接 1 Makefile 介绍 1.1 Makefile的规则 1.2 一个示例 1.3 ...
- 【无聊放个模板系列】HDU 3506 (四边形不等式优化DP-经典石子合并问题[环形])
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- js 实现list类
js中没有list类,可以使用Array来实现list类 (function(win) { var ArrayList = function() { this.datas = []; }; var p ...
- Spring中的实例生成方式及其生命周期
三种实例化bean的方式1.使用类构造器实例化 <!-- 使用类构造器实例化,class属性表示要使用的类的全限定名 --> <bean id="userDao1" ...
- SVN使用方法总结
SVN使用方法 SVN版本管理模式:http://www.cnblogs.com/newstar/archive/2011/01/04/svn.html (集中式-trunk和分散式-branch ...
- 跨域使用jsonp 获取天气预报
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> ...
- HDU4614【线段树。】
果然看了理解了一下大牛的代码然后自己敲结果果然有不少错误 回复说,线段树做为一种数据结构,最好以一种风格过一题裸的然后作为自己的模板.. 二分写的也很恶心哪 还有题目稍复杂一点的注定得推敲各种公式,不 ...
- Android 系统的四层结构
从上图中可以看出,Android 系统架构为四层结构,从上层到下层分别是应用程序层(Applications). 应用程序框架层 (Application Framework).系统运行库层(Libr ...
- [swustoj 1091] 土豪我们做朋友吧
土豪我们做朋友吧(1091) 问题描述: 人都有缺钱的时候,缺钱的时候要是有个朋友肯帮助你,那将是一件非常幸福的事情.有N个人(编号为1到N),一开始他们互相都不认识,后来发生了M件事情,事情分为2个 ...