Write a script with an infinite loop that provides the following options:
1. Enter items and print bill
2. Reprint
bill
3. Backup bill directory
4. ExitDetails:1. Enter items and print bill
Use an infinite loop to enter the following data:
item
number (serve as identifier)
quantity
Item numbers, items and prices are given as below:
105 Ring file RM 5.00
106 Paper box RM 6.00
107 Writing pad RM 7.00
108 A4 paper (70gm) RM 8.00
109 A4 paper (80gm) RM 9.00
For each item number entered, calculate the subtotal and store in file in the following format:Item no. Item Quantity Price Subtotal
: : : : :
: : : : :
Total:Use 200905 as the file name for the first bill and increment the number for new bill. Create a
directory calledbills to store all the files. Check the existence of the directory, if it does not
exist, create it, otherwise, remove the existing directory and create a new one.
NOTE:
Use 999 as item number to terminate the loop and then print the bill to the screen (i.e. display
the content of the most recently created file, the bill).
2. Reprint
bill
First of all, display all the file names in bills directory, then read file name from user and
display the content to the screen.
3. Backup bill directory
Backup the bills directory to a user specified destination (use appropriate name to avoid the
exisiting directory in the destination being overwritten), then remove the original bills
directory.
Optional requirement:
The name of thebills directory can be preceded by current day, month and year. For
example, 05Aug09_bills.
Hint:command date +%d%b%y will print the day, month and year, example: 05Aug09
Design the operation flow logically and use your creativity. Your script should perform any
checking (e.g value, file existence, etc.), if you think it is necessary to minimise errors in the
execution of your script.
I'm not clear on whether you have a question, or just wanted to issue a general challenge.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks