CodesChart Batch File C++ Flowchart VB6 Others About Privacy Policy

Monday, December 25, 2017

Simple Grading System in Batch File

Simple Grading System in Batch File is as easy like you are doing it in ++. But the difference is you don't need any kind of compiler to download and install. You can compile and run a batch file program using a CMD. You can see a batch program used as a calling program in most computer systems or program. Learning batch programming as most of the basic principle of programming.  

Grading System in Batch File (Source Codes)

If you can't see the entire codes properly just highlight it all and copy it to your favorite text editor. Also you can even set your browser in view "Desktop Site" in mobile browsers.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@echo off

:start
cls
set /p fname="Enter First Name: "
set /p mname="Enter Middle Name: " 
set /p lname="Enter Last Name: "
echo.
echo Choose number:
echo 1 First Year
echo 2 Second Year
echo 3 Third Year
echo 4 Fourth year
echo.
set /p yr="Enter number: "
if %yr% == 1 goto 1
if %yr% == 2 goto 2
if %yr% == 3 goto 3
if %yr% == 4 goto 4
:1
cls
echo first yr
set /p pl="Enter Pre Lim Grade: "
set /p mt="Enter Mid Term Grade: "
set /p pf="Enter Pre Finals Grade: "
set /p f="Enter Finals Grade: "

set /a total=%pl%+%mt%+%pf%+%f%
set /a total=%total%/4
echo.
echo %fname% %mname% %lname% 1st Year
echo.
echo Your Total Grade is %total%
pause
goto start
pause

:2
cls
echo Second yr
set /p pl="Enter Pre Lim Grade: "
set /p mt="Enter Mid Term Grade: "
set /p pf="Enter Pre Finals Grade: "
set /p f="Enter Finals Grade: "

set /a total=%pl%+%mt%+%pf%+%f%
set /a total=%total%/4
echo.
echo %fname% %mname% %lname% 2nd Year
echo.
echo Your Total Grade is %total%
pause
goto start

:3
cls
echo Third yr
set /p pl="Enter Pre Lim Grade: "
set /p mt="Enter Mid Term Grade: "
set /p pf="Enter Pre Finals Grade: "
set /p f="Enter Finals Grade: "

set /a total=%pl%+%mt%+%pf%+%f%
set /a total=%total%/4
echo.
echo %fname% %mname% %lname% 3rd Year
echo.
echo Your Total Grade is %total%
pause
goto start

:4
cls
echo Fourth yr
set /p pl="Enter Pre Lim Grade: "
set /p mt="Enter Mid Term Grade: "
set /p pf="Enter Pre Finals Grade: "
set /p f="Enter Finals Grade: "

set /a total=%pl%+%mt%+%pf%+%f%
set /a total=%total%/4
echo.
echo %fname% %mname% %lname%  4th Year
echo.
echo Your Total Grade is %total%
pause
goto start


How it works?

As you may already know you should have include "@echo off" at the beginning of the script, or your batch file program. You must be wondering why their is ":start" at the beginning of the script I'll explain it later. There come "cls" used to clear you work screen whenever you like to make a new. Then "set /p fname="Enter First Name: "" is declared as you have to know it is used to decide on where your input will be go or inserted, we used "set /p variable" to make a path on where variable you like to store your first name.

Now lets examine the process of selection area where the user will decide, on what year he/she included to show the grading system he/she like to use. We see "set /p yr="Enter number: "" used to make a selection on what year you choose. Then comes "if %yr% == 1 goto 1" used to make a decision on what year should pop up or show up to be used by the user itself. Then after the decision is made you'll go to ":1, :2, :3 and :4" depends on what ever the user input. Then you'll see "goto start" means the program will loop to the very first process shown in the program. About the arithmetic used in the program, well you see "set /a total=%pl%+%mt%+%pf%+%f%" used to do the math in the program, always remember whenever you are after mathematics in batch file programming keep in mind to used "set /a variable". One more thing you need to know you can't do the execution of decimal point in this program. This how a batch file program works.

Why Learning Batch File?

It leads you to learn on how to execute command prompt commands automatically. For example in the program or system that you have made, you'll like to delete, create or removed a folder as part of execution of your program or likewise a simple feature of your system. Knowing its capability make your works much easier. Have you ever wonder in some games or any kind of program that you used to install in your computer, when you are checking its folder you keep on seeing a bunch of batch file programs with ".bat" in the source folder. 

What are the needs in learning or executing Batch File?

You just need a plain text editor like notepad or any of your favorite text editor to do so. You did't have to download any kind of compiler, because it will compile it self whenever like to run it. But don't ever to forget on saving it as ".bat" on its extension, or else the operating system will not recognize it as a batch file program.

If you found this Article useful feel free to Click the Button below.

Buy Me A Coffee

2 comments:

  1. A Plain Text Editor
    Plain Text files
    That's right, if you're writer on a budget, you don't need to spend any money buying expensive writing software or apps. Instead, you can use the text editor that comes free with your operating system.
    Just open up Notepad on Windows or TextEdit on a Mac. I like plain text editors for writing something short quickly and easily, without thinking much about it. I wrote a blog post about the benefits of using plain text editors as writing software.
    Use for: writing whatever, wherever

    ReplyDelete