Click here to Skip to main content
15,071,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
  static void Main(string[] args)

            //Variable Declaration
            string studentName = "";
            string studentGrade = "";
            int studentScore = 0;
            double studentPercent = 0;

            //Output Greeting
            Console.WriteLine("Welcome to the Grade Calculator!: ");
            Console.WriteLine("The purpose of the grade calculator is to help calculate your students grade for !");

            //Input inputs
            Console.WriteLine("Please enter in the students name: ");
            studentName =  (Console.ReadLine());
            Console.WriteLine("Please enter in the students score: ");
            studentScore = Convert.ToInt32(Console.ReadLine());

            //Do Calculations
if (studentScore < 0 || > 1000) - This line gives an error stating my > variable is not right. HOW DO I FIX THIS
                Console.WriteLine("We apologize for the error. The value you entered in does not meet our criteria. Please enter in a number between 0 and 1000: ");


                studentPercent = studentScore / 1000;
                studentPercent = Convert.ToDouble(Console.ReadLine());

                Console.WriteLine("You have entered in a good score: ");

What I have tried:

I have tried using what visual studio suggested but it gives me more errors. I just want this one error to resolve. How do I do that.
Updated 25-May-18 19:52pm

This line if (studentScore < 0 || > 1000) should be

if (studentScore < 0 || studentScore > 1000)
Just to explain Bryian'c solution a little: '||' is the conditional OR operator, and it takes two bool values and returns a bool result:
bool result = a || b;
Where the result is true if either or both operands is true and false otherwise:
result   a      b
false    false  false
true     false  true
true     true   false
true     true   true
In C#, it is also defined that the condition a will be evaluated first, and if true, the condition b will not be evaluated at all (this is important later on)
So when you write an if condition that includes the OR operator, the left and right sides must be complete expressions which result in a bool value.

There is also an AND operator '&&' which returns true if both operands are true and false otherwise:
result   a      b
false    false  false
false    false  true
false    true   false
true     true   true
This also only evaluates b if a is true.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900