Basic If Statment BATCH CODING

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
maakuasa
Posts: 1
Joined: 28 Sep 2017 19:44

Basic If Statment BATCH CODING

#1 Post by maakuasa » 28 Sep 2017 19:54

Hi! Just a newbie here. I need some help regarding with my project. This is like my 1 time in batch coding and not familiar yet with the codes. My teacher gave me a homework where I need to create a grade system using batch file.

**************************************
The out should be like tis. When you enter the grade it should display the ff:
91-100 = Excellent
81-90 = Very Satisfactory
71-80 = Satisfactory
61-70 = Very Good
51-60 = Good
0-50 = Failed
**************************************
Now I tried the ff code:

If %num% is GRT 90 echo Excellent
If %num% LSS 50 echo Failed

The only problem is I don't know what copde I should use for the rest. As per my teacher there's no command '<=' pr '>=' is batch coding. Any tips how to solve this? There's another activity but it's pretty much the same. I just want to know how to to thru this and I'm pretty ure I will be able to figure the other activity. Thanks in advance!

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Basic If Statment BATCH CODING

#2 Post by Aacini » 28 Sep 2017 22:01

I am afraid I don't understand what exactly you want from us. Programmers may solve the same problem in different ways, and that depends on the way people thinks. There is no way to teach you to think in a certain way...

I suggest you to try different approachs until you advance in the solution and then make a specific question. The experience you will get via this method is a valuable thing you will not acquire in any other way.

Antonio

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Basic If Statment BATCH CODING

#3 Post by Squashman » 28 Sep 2017 22:07

Open up the cmd prompt.
Type the following command.

Code: Select all

IF /?

Reading is FUN!

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: Basic If Statment BATCH CODING

#4 Post by PaperTronics » 29 Sep 2017 06:09

I agree totally with Aacini and I suggest you first read the help of the IF command (the way to do that is described by Squashman) and then experiment with the multiple arguments of the IF command.

This method (Trial and Error) may take long, but if you have the time and if you put the right effort into it, you can be a professional Batch Programmer in only a few weeks.




Hope I helped,
PaperTronics

Post Reply