gpt4 book ai didi

C# 不明白从这里去哪里

转载 作者:太空宇宙 更新时间:2023-11-03 12:55:16 25 4
gpt4 key购买 nike

<分区>

我做这个作业已经有一段时间了,现在离完成还有 2 个问题...这个问题特别难倒我,我什至不确定我是否理解它的要求...已经很晚了,咖啡已经喝完了有人能指出我正确的方向吗...

**对于列表中的所有元素 letterGrades 如果索引 i 处的元素等于等级,则将 noOfGrades 递增 1。这无论大小写都应该进行比较,即对于 p/P/f/F。

Basic front end program

这是我到目前为止的当前代码列表...

/*
* Calculate letter grades as P for Pass and F for Fail based on the marks obtained.
* Find the number of instances with the given grades.
*/
namespace Ex1
{
public partial class LetterGrade : Form
{
// Initialize string List
public List<string> letterGrades = new List<string>();

public LetterGrade()
{
InitializeComponent();
}


private void submitButton_Click(object sender, EventArgs e)
{
double marks = double.Parse(marksTextbox.Text); //Declare variable marks and set

// If statements for marks
if (marks>0 && marks<=60)
{
letterGrades.Add("F");
}
else if (marks>60 && marks<=100)
{
letterGrades.Add("P");
}
else
{
MessageBox.Show("Not a valid marks");
}
marksTextbox.Clear();
}


private void calculateButton_Click(object sender, EventArgs e)
{
string grade = letterGradeTextbox.Text; // initialize string grade
int noOfGrades = 0;

for (int i = 0; i < letterGrades.Count; i++)
{
if (grade == "P" || grade == "p") //Problem here, step 7a...could not initialize using [i]..tried using a workaround but it keeps total count..
{
noOfGrades++;
}
else if (grade == "F" || grade == "f")
{
noOfGrades++;
}
}

letterGradeTextbox.Clear();

MessageBox.Show("Number of instances with given letter grade is: " + noOfGrades);
}
}
}

我很可能想得太多了,但如果有人能指出我正确的兔子洞,我将不胜感激

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com