TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kody Snow
NA
10
2.4k
Homework Question
Dec 7 2015 12:15 AM
This is the homework question....
For all elements in the List letterGrades a. If the element at index i is equal to grade, then increment noOfGrades by 1. This comparison should happen regardless of case, i.e., for p/P/f/F.
This is what i have so far....
/*
* 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);
}
}
}
I have no clue how to proceed any one that can point me int he right direction?
Reply
Answers (
9
)
bind control inside griedview
hide .aspx extension in browser?????