We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7.平均绩点
import java.util.*; import java.lang.*; public class Main{ public static Map<String,Integer> map = new HashMap<>(); static{ map.put("A",4); map.put("B",3); map.put("C",2); map.put("D",1); map.put("F",0); } public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNextLine()){ String line = sc.nextLine(); String[] items = line.split(" "); double sum = 0.0; int count = 0; boolean flag = false; for(String item:items){ if(map.get(item) != null){ sum += map.get(item); count++; }else{ flag = true; } } if (flag) { System.out.println("Unknown"); } else { System.out.printf("%.2f\n", sum / count); } } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
7.平均绩点
The text was updated successfully, but these errors were encountered: