Hello:)
I am asking the user to input a numerical grade into one textbox and then I want to show the corrosponding grade in the textbox below when they push a 'calculate' button. I have put it the code below and I am puzzled because I have listed 6 conditionals based on grade - but the only thing that will output is the data validation bit "Invalid 1-100 please". This outputs whatever number I put in! So doing my utmost not to get into a demented state I am trying to work this out logically and the only difference between the code that is kind enough to output, and the bit that isn't seems to be the brackets that hold the numeric conditions - but I have no errors - it took me a day to get it to output at all, and now I'm derailed :icon_eek: Could someone put me back on track please.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Task1._2_gradeConverter
{
/**
*Program created October 2010
*This program allows the user to enter a numerical grade from 0 to 100, click the convert
*or enter botton, and be astonished when the application calculates the letter score that
*corrosponds with the numerical *data. It then displays the result in a label on the form.
**/
public partial class Form1 : Form
{
int numGrade = 0;
//string letGrade; do I need a string for the letter Grade variable ???
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if((numGrade>87) && (numGrade>101))
{
textBox2.Text = numGrade.ToString("A");//Output A in Letter Grade textbox
}
else if((numGrade>79) && (numGrade>88))
{
textBox2.Text = numGrade.ToString("B");//Output B in Letter Grade textbox
}
else if((numGrade>66) && (numGrade>80))
{
textBox2.Text = numGrade.ToString("C");//Output C in Letter Grade textbox
}
else if((numGrade>59) && (numGrade>68))
{
textBox2.Text = numGrade.ToString("D");//Output D in Letter Grade textbox
}
else if ((numGrade > 62) && (numGrade > 0))
{
textBox2.Text = numGrade.ToString("F");//Output F in Letter Grade textbox
}
else
{
textBox2.Text = numGrade.ToString("Invalid 1-100 please");
}
}
private void label2_Click(object sender, EventArgs e)
{
//What about the Exit command- how on earth do I get this to close the program?????
}
}
}