第四章第十四题(转换字母等级为数字)(Convert letter grade to number)
-
*4.14(转换字母等级为数字)编写一个程序,提示用户输入一个字母等级A、B、C、D或者F,显示对应的数字值4、3、2、1或者0。对于其他输入,提示非法等级。
下面是一个运行示例:
Enter a letter grade: B
The numeric value for grade B is 3
Enter a letter grade: T
T is an invalid grade*4.14(Convert letter grade to number) Write a program that prompts the user to enter a letter grade A, B, C, D, or F and displays its corresponding numeric value 4, 3, 2, 1, or 0. For other input, display invalid grade.
Here is a sample run:
Enter a letter grade: B
The numeric value for grade B is 3
Enter a letter grade: T
T is an invalid grade -
参考代码:
package chapter04;
import java.util.Scanner;
public class Code_14 {