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 ...
随机推荐
- php继承与重载
<?php class A { public $param = "paramA"; public function test() { echo "testA&quo ...
- ArcGIS学习记录—KMZ KML与SHP文件互相转换
1.在google earth中绘制边界 工具栏中选择"Add Polygon".随意绘制一个多边形. 右击添加的图层名(左侧)保存位置为,选择保存为kmz或kml文件. ...
- classpath、path、JAVA_HOME的作用及JAVA环境变量配置
CLASSPATH是什么?它的作用是什么? 它是javac编译器的一个环境变量.它的作用与import.package关键字有关.当你写下improt java.util.*时,编译器面对import ...
- POJ1850——Code(组合数学)
Code DescriptionTransmitting and memorizing information is a task that requires different coding sys ...
- POJ3687——Labeling Balls(反向建图+拓扑排序)
Labeling Balls DescriptionWindy has N balls of distinct weights from 1 unit to N units. Now he tries ...
- 企业级 Linux 安全管理实例(1)
公司企业多用Linux服务器,其中涉及到的一些安全管理对于安全运维人员来说是必不可少的应知技能, 以下案例沿着背景->需求->具体要求->操作步骤的流程进行描述,可以加深对安全管理的 ...
- bzoj1030
AC自动机和DP. f[i][j] 表示在匹配到第i位置,处于ac自动机的j节点.决策第(i+1)个字母,计算出转移到第j2节点. f[i+1][j2] += f[i][j]; #include< ...
- c语言中 int *p = NULL 和 *p = NULL 有什么区别
1. int *p = NULL; 代表定义一个指向整型变量的指针p,然后p的值设为NULL,也就是设为0:用另一种方式说,就是对一个刚定义的指向整型变量的指针,赋初始值,让其指向0地址. 2. *p ...
- java适配器模式
原文查看:http://www.cnblogs.com/java-my-life/archive/2012/04/13/2442795.html
- MySQL join的实现原理及优化思路
Join 的实现原理 在MySQL 中,只有一种Join 算法,也就是Nested Loop Join,没有其他很多数据库所提供的Hash Join,也没有Sort Merge Join.顾名思义,N ...