Microsoft C#中的控制台编程 [英] Console programming in microsoft c#

查看:57
本文介绍了Microsoft C#中的控制台编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简介:
编写一个C#程序,允许用户输入学生信息并为学生输出适当的成绩.这种分配涉及类,数组或集合,循环和方法的使用.
结果类:
创建一个名为Result.cs的类,它作为主类.该课程将首先提示用户输入学生记录的数量.您将基于此信息创建一个数组.该程序将学生姓名,分数和成绩的列表读入数组.这是通过循环并提示用户逐个输入名称和标记来完成的. (学生姓名不得重复).成绩会根据所提供的分数自动计算出来. Result类应包含以下选项:
1.显示学生分数
2.更改学生分数
3.打印出所有学生的信息
4.退出程序

学生班:
创建一个名为Student.cs的类.此类包含以下内容:
a)类数据字段的名称,标记和等级
b)公共学生(字符串名称,双标记,字符串等级)
//构造函数

c)公共字符串getName()//返回学生的姓名
d)public double getMark()//返回学生的分数
e)公共字符串getGrade()//返回学生成绩
f)public void setMark(double mark)//设置学生分数
g)公共字符串setGrade(double mark)//首先使用嵌套的if-else检查标记并切换以确定等级.
可能的等级是:
0< =标记< 50-
50< =标记< 60-
60< =标记< 70-
70< =标记< 80-
80< =标记< 100-
样本输出:
请输入您要添加的学生分数数量:2
请输入学生1的姓名:Sam
请输入学生1:33的分数
请输入学生2的姓名:约翰
请输入学生2的分数:88
选择一个选项:
1.显示学生分数
2.更改学生分数
3.打印出所有学生的信息
4.退出程序
输入选项:1
显示学生成绩
请输入您要显示分数的学生的姓名:jjj
对不起.学生:"jjj"不存在
选择一个选项:
1.显示学生分数
2.更改学生分数
3.打印出所有学生的信息
4.退出程序
输入选项:1
显示学生成绩
请输入您要显示分数的学生的姓名:Sam
山姆的分数是:33.0
选择一个选项:
1.显示学生分数
2.更改学生分数
3.打印出所有学生的信息
4.退出程序
输入选项:2
更改学生分数
请输入您要更改其商标的学生的姓名:John
约翰的当前分数是:88.0
为约翰输入新的标记:3333
输入无效!标记必须在0-100之间!
为约翰输入新的分数:70
约翰的新成绩是:D
选择一个选项:
1.显示学生分数
2.更改学生分数
3.打印出所有学生的信息
4.退出程序
输入选项:3
打印所有学生的信息
名称标记等级
山姆33.0 F
约翰70.0 D
选择一个选项:
1.显示学生分数
2.更改学生分数
3.打印出所有学生的信息
4.退出程序
输入选项:4
感谢您使用系统.再见!


我无法解决它,所以请为我提供解决方案.

Introduction:
Write a C# program which allows the user to enter student information and outputs the appropriate grade for the student. This assignment involves the use of classes, arrays or collections, loops and methods.
Result Class:
Create a class called Result.cs which serves as the main class. This class will first prompt the user for number of student records. You will create an array based on this information. The program reads a list of student names, marks and grades into an array. This is done using a loop and prompting the user to enter the names and marks, one by one. (The student name should not be duplicate).The grade is automatically computed based on the mark provided. The Result class shall include the following options:
1. Display a Student Mark
2. Change Student Mark
3. Print out information for all students
4. Exit program

Student Class:
Create a class called Student.cs. This class contains the following:
a) class data fields name, mark and grade
b) public Student (string name, double mark, string grade)
// constructor

c) public string getName() / / to return name of student
d) public double getMark() // to return mark of student
e) public string getGrade() // to return student grade
f) public void setMark(double mark) // to set student mark
g) public string setGrade(double mark) // mark is first checked using a nested if-else and switch to determine grade.
The possible grades are:
0 <= mark < 50 -
50 <= mark < 60 -
60 <= mark < 70 -
70 <= mark < 80 -
80 <= mark < 100 -
Sample Output:
Please enter number of student marks you would like to add: 2
Please enter name of student 1 : Sam
Please enter mark for student 1 : 33
Please enter name of student 2 : John
Please enter mark for student 2 : 88
Choose an option:
1. Display a Student Mark
2. Change Student Mark
3. Print out information for all students
4. Exit program
Enter Option: 1
Display a student mark
Please enter name of student you would display mark for: jjj
I am sorry. Student: ''jjj'' does not exist
Choose an option:
1. Display a Student Mark
2. Change Student Mark
3. Print out information for all students
4. Exit program
Enter Option: 1
Display a student mark
Please enter name of student you would display mark for: Sam
Marks for Sam is: 33.0
Choose an option:
1. Display a Student Mark
2. Change Student Mark
3. Print out information for all students
4. Exit program
Enter Option: 2
Change Student Mark
Please enter name of student you would like to change mark for: John
Current marks for John is: 88.0
Enter new mark for John: 3333
Invalid Entry! Marks must be between 0 - 100!
Enter new mark for John: 70
New grade for John is: D
Choose an option:
1. Display a Student Mark
2. Change Student Mark
3. Print out information for all students
4. Exit program
Enter Option: 3
Print out information for all students
Name Mark Grade
Sam 33.0 F
John 70.0 D
Choose an option:
1. Display a Student Mark
2. Change Student Mark
3. Print out information for all students
4. Exit program
Enter Option: 4
Thank you for using the system. Good bye!


I was unable to solve it so kindly provide me with solution.

推荐答案

在这里不起作用.显然,这是一项家庭作业,我们不是在这里为您做家庭作业.您需要做的是展示一定程度的努力.当您遇到代码问题时,您可以在这里表达这些担忧,我们很乐意抽出时间来帮助您.就目前情况而言,您需要先完成工作.
It doesn''t work that way here. This is clearly a homework assignment and we are not here to do your homework for you. What you need to do is demonstrate some level of effort. When you run into code issues you can express those concerns here and we will gladly volunteer our time to help you out. As it stands you need to do the work first.


如果要发布作业,至少要使其看起来像是您自己尝试做某事!

我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试,或学习魔语:您要用它炸薯条吗?"
If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"


这篇关于Microsoft C#中的控制台编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆