帮助!我觉得我有点不知所措,我正在尝试创建一个小程序让用户执行以下操作
伪代码
导入扫描仪
定义变量 numStudents numExams studscore studgrade userIn keepGoing
询问用户有多少学生,设置为 numStudents
询问用户有多少考试,设置为 numExams
为 numstudents numExams 创建二维数组 studentResults
虽然一直保持 == 真
要求用户按 E 退出,按 S 输入学生的考试成绩,或按 C 检查最终成绩 将输入解析为 char 如果退出,退出程序,设置 keepGoing 为 false 否则如果 S,询问学生编号,创建 For 语句让用户输入所有考试成绩并存储该学号否则如果 C,则询问学号,显示结果否则显示消息,这是无效的选项
* * *到目前为止我有这个....
我试图找出如何让用户输入他们的分数(询问他们的学号是什么(第一个数组部分),然后输入他们的该学号的考试成绩。
然后第 2 部分,回到 while 循环,如果他们选择查看最终成绩,程序会询问他们的学号并返回该学号的平均分数。
import java.util.*;
import javax.swing.JOptionPane;
public class examgrades {
public static void main(String[] args)
{
//Define variables
int numStudents=0;
int numExams=0;
int studScore=1;
char studGrade='a';
int studChoice=1;
char userChoice;
boolean keepGoing=true;
//Get number of students
System.out.println("Please enter the number of Students: ");
Scanner reader = new Scanner(System.in);
numStudents=reader.nextInt();
//Get number of Exams
System.out.println("Thank you, now please enter the number of exams this semester: ");
Scanner reader1 = new Scanner(System.in);
numExams=reader1.nextInt();
//Create array
int [][] studentResults = new int [numStudents][numExams];
//Create intial program loop
while (keepGoing);
//Ask user to Press S to enter exam scores for a student, C to check a final grade, or E to Exit
System.out.println("Press S to enter exam scores for a student, C to check a final grade, or E to Exit");
Scanner reader2 = new Scanner(System.in);
String userIn=reader2.nextLine();
//Parse into Char
userChoice=userIn.charAt(0);
//Check for exit
if (userChoice=='e' || userChoice=='E') {keepGoing=false; System.out.println("Program is exiting... \n");}
//Enter Scores if User chose S
//Check final Grade if user chose C