The next exercise from this topic is to write a console program that inputs the grade (decimal number) and prints Excellent! if the grade is 5.50 or higher, otherwise "Not excellent.".
Input | Output |
---|---|
6 | Excellent! |
5 | Not excellent. |
5.5 | Excellent! |
5.49 | Not excellent. |
First, we create a new C# console project in the Simple-Conditions solution.
-
We click on the solution in Solution Explorer and choose [Add] -> [New Project].
-
We choose [Visual C#] -> [Windows] -> [Console Application] and specify a name, for example: “Excellent-or-Not”.
Now we have to write the code of the program. You can get help by using the sample code from the picture:
If try to run the program using [Ctrl+F5], the result might be incorrect, because it might be the result from the previous project, not the current one, shown at the screen.
We turn on the mode for automatic switching to the current project by right-clicking on the main Solution and choosing [Set StartUp Projects...]:
A dialog box will appear, and you have to choose [Startup Project] -> [Current selection]:
Now we run the program as usual with [Ctrl + F5] and test if it works correctly:
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/506#1.