- Oct 29, 2005
- 87
- 0
- 0
I am trying to write a windows shell script to calculate student grades for my class
and i am having trouble, I can get it to display the letter grades but not the grades
as numbers, I need to display both. The file is l7-grades.bat and when you run it you have to type a studentid number and then the grade, and it is supposed to show your student id number, grade as a number, and grade as a letter. For for example l7-grades.bat 1234 90 is supposed to show 1234 as your student id number 90 as your number grade and an A as your letter grade. I am also having trouble getting it to output to a text file. Here is my script:
REM COMP230 INTRODUCTION TO SCRIPTING AND DATABASE WITH LAB
REM Author:Cooper McKay SECTION ID: 230 Date: 9-10-07
REM
REM LAB 7 - Decision making
REM Script name: L7-grades.bat
REM Function:
REM This Script is used to calculate grades of students.
@echo off
cls
REM echo follows by a . generates a blank line
echo.
echo ========
Echo this program calculates student grades of students and outputs them to a text file.
echo ========
echo.
REM Convert first argument to integer
set /a id=%1
set /a grades=%2
if %id% lss 1 goto student id-error else (
if %grades% lss 1 goto grade-error else (
)
)
echo. > l7-grades.txt
echo Student ID Scores Grade
echo ---------- ------ -------
REM Outputs above message to l7-grades.txt
REM del l7-grades.txt
if %grades% GTR 89 (echo %id% A) else (
if %grades% GTR 79 echo %id% B
if %grades% GTR 69 echo %id% C
if %grades% GTR 60 echo %id% D
if %grades% LSS 60 echo %id% F
)
)
goto :EOF
:grade-error
Echo **Error: The grades must be greater than zero
goto :EOF
:studentid-error
Echo **Error: The student id number must be greater than zero.
goto :EOF
)
)
and i am having trouble, I can get it to display the letter grades but not the grades
as numbers, I need to display both. The file is l7-grades.bat and when you run it you have to type a studentid number and then the grade, and it is supposed to show your student id number, grade as a number, and grade as a letter. For for example l7-grades.bat 1234 90 is supposed to show 1234 as your student id number 90 as your number grade and an A as your letter grade. I am also having trouble getting it to output to a text file. Here is my script:
REM COMP230 INTRODUCTION TO SCRIPTING AND DATABASE WITH LAB
REM Author:Cooper McKay SECTION ID: 230 Date: 9-10-07
REM
REM LAB 7 - Decision making
REM Script name: L7-grades.bat
REM Function:
REM This Script is used to calculate grades of students.
@echo off
cls
REM echo follows by a . generates a blank line
echo.
echo ========
Echo this program calculates student grades of students and outputs them to a text file.
echo ========
echo.
REM Convert first argument to integer
set /a id=%1
set /a grades=%2
if %id% lss 1 goto student id-error else (
if %grades% lss 1 goto grade-error else (
)
)
echo. > l7-grades.txt
echo Student ID Scores Grade
echo ---------- ------ -------
REM Outputs above message to l7-grades.txt
REM del l7-grades.txt
if %grades% GTR 89 (echo %id% A) else (
if %grades% GTR 79 echo %id% B
if %grades% GTR 69 echo %id% C
if %grades% GTR 60 echo %id% D
if %grades% LSS 60 echo %id% F
)
)
goto :EOF
:grade-error
Echo **Error: The grades must be greater than zero
goto :EOF
:studentid-error
Echo **Error: The student id number must be greater than zero.
goto :EOF
)
)