| | |
GPA Calculator
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Solved Threads: 0
I need some help. I want to be able to put in a letter grade within a textbox of a class and have the program know that A is 4.0 (A=4.0) then calclulate the GPA by adding all the class grades and dividing by seven which is the number of classes which equals the GPA.
This is what it looks like:
A = 4.0
A- =3.7
B+ = 3.3
B = 3.0
B- =2.7
C+=2.3
C=2.0
C-=1.7
NG = 0
My code looks like this so far it just doesn't know how to interpret A as 4.0 and calculate the GPA:
http://img159.imageshack.us/img159/3107/gpacalcgy7.png
If you could help me on this it would be greatly appreciated.
This is what it looks like:
A = 4.0
A- =3.7
B+ = 3.3
B = 3.0
B- =2.7
C+=2.3
C=2.0
C-=1.7
NG = 0
My code looks like this so far it just doesn't know how to interpret A as 4.0 and calculate the GPA:
http://img159.imageshack.us/img159/3107/gpacalcgy7.png
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace gpacalc { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void label4_Click(object sender, EventArgs e) { } private void textBox8_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { int x = 0; try { double g1 = Convert.ToDouble(textBox1.Text); double g2 = Convert.ToDouble(textBox2.Text); double g3 = Convert.ToDouble(textBox3.Text); double g4 = Convert.ToDouble(textBox4.Text); double g5 = Convert.ToDouble(textBox5.Text); double g6 = Convert.ToDouble(textBox6.Text); double g7 = Convert.ToDouble(textBox7.Text); textBox8.Text = Convert.ToString((g1 + g2 + g3 + g4 + g5 + g6 + g7) / 7.0); } catch { Console.Write(textBox8.Text = "ERROR"); Console.Beep(x = 266, x = 300); } } private void textBox1_TextChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { Close(); } } }
If you could help me on this it would be greatly appreciated.
Last edited by cscgal; Nov 30th, 2007 at 1:03 am. Reason: Added code tags
•
•
Join Date: Aug 2007
Posts: 164
Reputation:
Solved Threads: 1
1st
dont calculate and display in a text box in one move. first calculate to a variable.
2nd
now you can use g8 in a series of selection structures structure
and so on until each grade is checked for. now you display the value of g8 in a textbox and the of s1, which is the grade, as well.
dont calculate and display in a text box in one move. first calculate to a variable.
C# Syntax (Toggle Plain Text)
g8 = (g1 + g2 + g3...... + g7) / 7.0;
2nd
now you can use g8 in a series of selection structures structure
C# Syntax (Toggle Plain Text)
string s1; if ( g8 > 3.7 && g8 <= 4.0 ) s1 = "A"; if ( g8 > 3.3 && g8 <= 3.7 ) s1 = "B";
Last edited by Ravenous Wolf; Nov 30th, 2007 at 3:07 am.
... what society overwhelmingly asks for is snake oil. Of course, the snake oil has the most impressive names —otherwise you would be selling nothing— like "Structured Analysis and Design", "Software Engineering", "Maturity Models", "IPSE", "MIS", "OO", "BPRE".... by Edsger W. Dijkstra
![]() |
Similar Threads
- Starting Python (Python)
- Homework, GPA Calculator (C++)
- Student GPA (Python)
- Tell us about yourself! (Community Introductions)
- Help (C)
Other Threads in the C# Forum
- Previous Thread: binary search trees
- Next Thread: 2D graphic
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mailmerge mandelbrot math mouseclick mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox robot save saving serialization server sleep socket sql statistics stream string stringformatting table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





