Computing.Net > Forums > Unix > Help with shell script

Help with shell script

Reply to Message Icon

Original Message
Name: vh3xz
Date: November 19, 2007 at 08:40:58 Pacific
Subject: Help with shell script
OS: Unix
CPU/Ram: 2 gigs
Comment:

I have no idea on how to do this project at all was wondering if anyone had any useful tips on this project. Thanks all ahead of time that reply to this! :D

Here are the rules:

This description contains pseudocode – a model for writing a script – or program.

Build a script that will let you balance your checkbook. The name of the script is checkbook. You must use integer numbers! No decimal points!

Use tput commands to control the screen when

· Asking for the initial balance,

· Displaying the new balance

· Asking for the amount of a check

This script asks for an initial balance which represents the balance in your checkbook. The initial balance is assumed to be positive.

A transaction file is maintained by the script. This file (see below) keeps a record of the initial balance, each check amount and each calculated new balance. The transaction file is initialized with the “start” line as shown in the example below.

Before entering step 2 loop, set check amount to non-zero value.

Step 2

Loops as long at the check amount is not zero.

The script then displays the new balance and then asks the user to enter a check amount.

Step 3

If the check amount is not zero, then . . .

Writes the check amount to the transaction file.

Calculates a new balance by subtracting the check amount from the previous balance.

Writes the new balance to the transaction file.

Else (check amount = 0)

Clears the screen.

Sets up the “end” and current date variables

Writes the end and current date variable info to the checkbook file.

Echoes the name of the checkbook file to the screen. This line precedes the display of the contents of the transaction file.

Display the content of the checkbook file on the screen.

End If

Loops back to Step 2

End of script.

SAMPLE TRANSACTION FILE

Note: A comma (,) is used as the field separator in this file.

start,Sun Nov 4 19:40:23 MST 2007

InitialBalance,2500

CheckAmount,-500

NewBalance,2000

CheckAmount,-100

NewBalance,1900

CheckAmount,-300

NewBalance,1600

CheckAmount,-400

NewBalance,1200

CheckAmount,-300

NewBalance,900

CheckAmount,-50

NewBalance,850

end,Sun Nov 4 19:40:36 MST 2007


Report Offensive Message For Removal








Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Help with shell script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge