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 ...
随机推荐
- ***phpredis扩展安装总结
phpredis扩展安装总结:PHP扩展安装在[root@iZ254lfyd6nZ lampp]# cd include 目录下创建一个目录phpredis下载扩展:wget https://gith ...
- 李洪强iOS开发之【零基础学习iOS开发】【02-C语言】06-变量与内存
在前面一节中简单介绍了变量的使用,当我们定义一个变量的时候,系统就会为变量分配一块存储空间.而变量的数值在内存中是以二进制的形式存储的,这讲来深入研究变量在内存中的一些存储细节. 一.字节和地址 为了 ...
- [itint5]两数积全为1
http://www.itint5.com/oj/#18 这一题,首先如果直接去算的话,很容易就超出int或者long的表示范围了.那么要利用%的性质,(num * 10 + 1) % a = 10 ...
- *[topcoder]GooseTattarrattatDiv1
http://community.topcoder.com/stat?c=problem_statement&pm=12730&rd=15701 这道题有点意思.首先把字符串变成回文, ...
- Java Web开发 之小张老师总结中文乱码解决方案
中文乱码:在以后学习过程中全部采用UTF-8 1.文件的乱码 1.1.项目文本文件默认编码: [右击项目]->[Properties]->[Resource]->[Te ...
- Android UI-开源框架ImageLoader的完美例子
Android开源框架ImageLoader的完美例子 2013年8月19日开源框架之Universal_Image_Loader学习 很多人都在讨论如何让图片能在异步加载更加流畅,可以显示大量图片, ...
- WinAPI你知道多少?!(上千个,好多都没见过)
http://www.cnblogs.com/vanver/archive/2013/06/13/NO-2013_06_13pm.html 播客开篇,讲讲废话:本篇播客只是推荐给热与钻研的同学们... ...
- JavaScript基本程序结构
条件判断 JavaScript使用if () { ... } else { ... }来进行条件判断.例如,根据年龄显示不同内容,可以用if语句实现如下: var age = 20; if (age ...
- brew,gem,rvm 和 bundler软件包的管理工具
brew是OS X上提供软件包的管理.Homebrew将软件包安装到单独的目录,然后符号链接到/usr/local 中,完全基于git和ruby.使用gem来安装你的gems,用brew来搞定他们的依 ...
- cf 189B - Counting Rhombi
题目:189B - Counting Rhombi http://codeforces.com/problemset/problem/189/B 题意:给定一个长方形的 矩形,求能在这个矩形里有多少 ...