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 ...
随机推荐
- 解决Oracle ORA-00984: column not allowed here
某列是字符列,结果忘记加单引号了 INSERT INTO prt_document_present (company_code, doc_no, seq_no, field_name, desc_ms ...
- uva 11143
#include<cstdio> #include<cstring> #include<algorithm> #define maxn 5100 #include& ...
- uva10943
递推 还是比较容易的 /************************************************************************* > Author: ...
- Kafka 之 async producer (1)
问题 很多条消息是怎么打包在一起的? 如果消息是发给很多不同的topic的, async producer如何在按batch发送的同时区分topic的 它是如何用key来做partition的? 是如 ...
- Linux下去掉^M的方法
cat -A filename 就可以看到windows下的断元字符 ^M 要去除他,最简单用下面的命令: dos2unix filename 第二种方法: sed -i 's/^M//g ...
- POJ 1850 Code(组合数)
http://poj.org/problem?id=1850 题意 :给定字符串,系统是用字符串组成的,字符串是按字典序排的.编码系统有三条规则,1这些的单词的长度是由小到大的,2相同长度的按字母在字 ...
- PYTHON设计模式,创建型之工厂方法模式
我感觉和上一个差不多,可能不要动最要的地方吧... #!/usr/bin/evn python #coding:utf8 class Pizza(object): def prepare(self, ...
- tomcat context 配置 项目部署
将tomcat/conf/server.xml文件打开, 在</Host>标签之前添加: <Context path = "" docBase = "F ...
- Android 签名(6)编译时源码的签名
1,使用源码中的默认签名 在源码中编译一般都使用默认签名的,在某源码目录中用运行下面命令能看到签名命令. $ mm showcommands Android提供了签名的程序signapk.jar,用法 ...
- Android 签名(4)验证是否签名
判断Apk是否签名 用命令:jarsigner -verify XXX.apk 增加 -verbose -certs 两个选项可显示更多信息. 如果有Android Debug字樣就是debug 如 ...