Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am making a C# program in visual and i cant figure out the foreach loop to calculate the average GPA of items in my
I am making a C# program in visual and i cant figure out the foreach loop to calculate the average GPA of items in my list once they have been added to it. Heres my code please help.
50 // declare vars decimal decCurrent = 0.60m; decimal decRunningTotal = 0.98m; decimal decCurrentGPA = 0.00m; 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 int intNumberOfCourses = 0; int intTotalCredits = 0; 1/count items in the radio button list intNumberOfCourses = Convert.ToInt32(rblClasses0.Items.Count); 1/add number of courses //take number of courses and mult by 3 for credits 1b1NumberCourses. Text = rblClasses0.Items.Count.ToString(); intTotalCredits = intNumberOfCourses * 3; 1b1TotalCredits.Text = intTotalCredits.ToString(); 67 68 69 //calculate gpa foreach (ListItem listItem in rbiclasses. Items) { decCurrent = Convert.ToDecimal(listItem.Value); decRunningTotal += decCurrent; decCurrentGPA = decRunningTotal / Convert.ToDecimal(intNumberOfCourses); 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 lblCurrentGPAQ.Text = decCurrent GPA.ToString(); /** liNumber.Value = Convert.ToDecimal(1 Number.Value); intCurrentGPA = Convert.ToInt32(1iNumber.Value); intCurrentGPA = intCurrentGPA / int NumberOfCourses; No issues found 75 % Error List Entire Solution Code X 0 Errors 1 Warning 60 of 11 Messages *7 Build + IntelliSense Description Validation (HTML5): Element 'table' cannot be nested within element 'span'. Grade Summary System harris, james (Business Analytics) Course History (Add a New Course) Course Prefix: Course Number: Grade Earned: Submit Summary Number of Courses: unknown Current GPA: 0.0 Total Credits: 0 * assuming all courses are 3 credits Cancel A A- B+ Start Over B B- C+ C- D+ D D- F 50 // declare vars decimal decCurrent = 0.60m; decimal decRunningTotal = 0.98m; decimal decCurrentGPA = 0.00m; 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 int intNumberOfCourses = 0; int intTotalCredits = 0; 1/count items in the radio button list intNumberOfCourses = Convert.ToInt32(rblClasses0.Items.Count); 1/add number of courses //take number of courses and mult by 3 for credits 1b1NumberCourses. Text = rblClasses0.Items.Count.ToString(); intTotalCredits = intNumberOfCourses * 3; 1b1TotalCredits.Text = intTotalCredits.ToString(); 67 68 69 //calculate gpa foreach (ListItem listItem in rbiclasses. Items) { decCurrent = Convert.ToDecimal(listItem.Value); decRunningTotal += decCurrent; decCurrentGPA = decRunningTotal / Convert.ToDecimal(intNumberOfCourses); 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 lblCurrentGPAQ.Text = decCurrent GPA.ToString(); /** liNumber.Value = Convert.ToDecimal(1 Number.Value); intCurrentGPA = Convert.ToInt32(1iNumber.Value); intCurrentGPA = intCurrentGPA / int NumberOfCourses; No issues found 75 % Error List Entire Solution Code X 0 Errors 1 Warning 60 of 11 Messages *7 Build + IntelliSense Description Validation (HTML5): Element 'table' cannot be nested within element 'span'. Grade Summary System harris, james (Business Analytics) Course History (Add a New Course) Course Prefix: Course Number: Grade Earned: Submit Summary Number of Courses: unknown Current GPA: 0.0 Total Credits: 0 * assuming all courses are 3 credits Cancel A A- B+ Start Over B B- C+ C- D+ D D- F
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started