Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Purpose of this program: To implement windows batch commands 1 - Worth 0.50 poin

ID: 3707756 • Letter: P

Question

 Purpose of this program: To implement windows batch commands     1 - Worth 0.50 points. Using Windows batch Scripting.       - Using Windows terminal command, create a bat file named:        name.bat      - Using the NOTEPAD editor, append the following data to your *.bat file         USING MULTI-LINE COMMENTS:       ********************************************************************        Author    : Your Name           *********************************************************************/     2 - Worth 2.75 points. Using Windows batch Scripting.       topic: Implement division by 0, with error trapping, using if and sumilating              while loops      - Using the NOTEPAD editor, append to the *.bat file, all the commands needed        so that when you execute your bat file, it will produce the following:       a) Append your name and class name and section.      b) Using two variables: FirstNumber and LastNumber,       c) Ask the user to enter the first number.      d) Ask the user to enter the second number.      e) If the user enters the value 99 for the first or the second number, you must         exit the loop immediately, and terminate this section ONLY.      f) If the second number is ZERO inform  the user that you CAN NOT divide by ZERO,         and ask for a correct second number.      g) If the second number is NOT a zero, do the division, display all numbers of          this computation using labels,                   example: 4 divided by 1 = 4     3 - Worth 2.75 points. Windows batch Scripting.      - Using the NOTEPAD editor, append to the *.bat file, all the commands needed so        that when you execute your bat file, this file will produce the following:           a) Using a for loop      b) Find the results of calculating each number from (10 to 1 mod 6)       c) After the for loop ends, display the average for all previous results    

Explanation / Answer

ANSWER:

Batch file is a kind of script file containing a list of computer commands/instructions to be carried out in sequence.

1.Batch files are normally created in notepad editor in windows.

In notepad editor , type the following commands:

echo MyFirstBatchFile

Save this file using "Save AsType" -->"All Files" -->" yourLastNameFirstNameInitialPgm4.bat"

Create another such notepad file "appenddata.txt"and type the followind data and save.

USING SINGLE LINE COMMENTS FOR EACH LINE

       Author    : Your Name

       Course    : OS section. Example OS1, OS2 OS3, OS4

       Professor : Michael Robinson

       Program # : Program Purpose/Description

                   { A brief description of the program }

               

       Due Date : MM/DD/YYYY

                

                 

       Certification:

       I hereby certify that this work is my own and none of it is the work of any other person.

        

Go to Start and type Run. Next,Type:

CMD

It opens up the command prompt of Windows.

Hit Enter.

From the command prompt, type:

echo > yourLastNameFirstNameInitialPgm4.bat

Hit Enter.

TYPE appenddata.txt >>yourLastNameFirstNameInitialPgm4.bat

The typed code will be displayed on the screen.

2.

a)Using notepad editor, create the "results.txt" file.

We append our name, current date and time to this file, results.txt

set /p UserInfo= "Enter second number "

setx LastNumber "%LastNumber%"

:MAIN

cls

:FIRSTNUM

ECHO ENTER FIRST NUMBER

SET /P FIRSTNUM=Enter First number and press ENTER :

IF %FIRSTNUM%==66 GOTO FORLOOP

GOTO LASTNUM

:LASTNUM

ECHO ENTER SECOND NUMBER

SET /P LASTNUM=Type SECOND number and press enter :

IF %LASTNUM%==66 GOTO FORLOOP

IF %LASTNUM%==0 GOTO ASKAGAIN

IF NOT %LASTNUM%==66 GOTO DIVISION

IF NOT %LASTNUM%==0 GOTO DIVISION

:ASKAGAIN

ECHO.

ECHO CANNOT DIVIDE BY ZERO, PLEASE ENTER TWO NEW NUMBERS

GOTO FIRSTNUM

:DIVISION

ECHO.

SET /A RESULT=%FIRSTNUM% / %LASTNUM%

ECHO %FIRSTNUM% divided by %LASTNUM% is %RESULT%

@ECHO %FIRSTNUM% divided by %LASTNUM% is %RESULT% >> results.txt

GOTO FIRSTNUM

:FORLOOP

cls

PAUSE

GOTO LOOP

GOTO EXITLOOP

:EXITLOOP

PAUSE EXIT /B

3.

@echo off

:FORLOOP

cls

PAUSE

SET COUNTER=1

SET MODNUM=6

SET ADDNUM=2

SET RESULT=0

SET TOTAL=0

SET AVG=0

GOTO LOOP

:AVG

ECHO.

ECHO %TOTAL%

SET /A "AVG=(%TOTAL% / 10)"

ECHO AVERAGE OF RESULTS IS %AVG%

ECHO.

@ECHO AVERAGE OF RESULTS IS %AVG% >> results.txt

GOTO EXITLOOP

:EXITLOOP

4)

Creating a new directory using Windows terminal mode commands,

C:>mkdir pgm4-

C:> cd pgm4-

C:>pgm4->notepad one.txt

C:/>pgm4->echo Name:John>one.txt

C:/>pgm4->one.txt>echo

C:/>pgm4->one.txt>echo.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote