UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2013, 07:56 PM
prince13 prince13 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 prince13 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 8 sec
Reputation Power: 0
Need some help

can someone help me here?


Create a script that computes for the total parking charge of a customer.
The following information are to be collected as inputs from the standard input:
Plate number (format: 7 characters, the first 3 are characters from A to Z followed by a dash followed by a 3 digit number; i.e.: XXX-123)
Time in (format: military time; i.e. 1500 => 3 PM)
Time out (format: military time; i.e. 1900 => 7 PM)
Type of vehicle: can either be the following characters:
L, U or H which stands for Light vehicle, Utility vehicle or heavy vehicle respectively.

The parking lot operates starting at 7 AM and closes at 11:30 PM.

The rates in the parking lot are as follows:
Standard parking fee (minimum of 2 hours) = 50 pesos
Succeeding hour or less in excess of 2 hours for:
Light vehicles = 5 pesos
Utility vehicles = 15 pesos
Heavy vehicles = 25 pesos
Furthermore, the maximum parking charge for the following vehicles applies:
Light vehicles = 100 pesos
Utility vehicles = 150 pesos
Heavy vehicles =250 pesos

The script should be able to validate whether the time in and time out values are VALID inputs based on the value that is entered (time out > time in, digits only). Other validations are not to be filtered by the script. The output of the script is the parking charge of the vehicle and its details.


Sample run 1: [prompt]$ <your familyname>parkingbill

Enter the plate number (i.e.: AAE-775): XNY-123
Enter the type of vehicle (L/U/H): U
Enter the time the vehicle entered the parking lot: 0845
Enter the time the vehicle entered the parking lot: 1915

The vehicle with plate number XNY-123 was parked for 10 hours and 30 minutes. The parking charge for the vehicle is 150 pesos

Try again Y/N? N
[prompt]$

Sample run 2: [prompt]$ <your family name>parkingbill

Enter the plate number (i.e.: AAE-775): GMA-111
Enter the type of vehicle (L/U/H): L
Enter the time the vehicle entered the parking lot: 1245
Enter the time the vehicle entered the parking lot: 1315

The vehicle with plate number XNY-123 was parked for 0 hours and 30 minutes. The parking charge for the vehicle is 50 pesos

Try again Y/N? N
[prompt]$


and this is my unfinish code. ====>

loop=y
while test "$loop" = "y"
do
clear
tput cup 1 1; echo -n "Enter the plate number (i.e: AAE-775):"
tput cup 1 40; read plate
if [[ !($platenum != [A-Z][A-Z][A-Z]-[0-9][0-9][0-9]) ]];
then
tput cup 2 1; echo "Enter the type of vehicle ([L]/[U]/[H]);"
else echo -n "INVALID PLATE NUMBER!"
fi
tput cup 2 42; read type
if [[ !($type != [L]) ]] || [[ !(type != [U]) ]];
then
tput cup 3 1; echo "Enter the time the vehicle entered the parking lot:"
tput cup 3 1; echo "Enter the time the vehicle exited the parking lot:'
else echo -n "INVALID TYPE!"
fi
tput cup 3 55; read timein;
tput cup 4 55; read timeout;
let timet=$[timein + timeout];
tput cup 6 1; echo -n "The vehicle with plate number $platenum was parked for $timet :"
tput cup 7 1; echo -n "Try again y/n?:"
tput cup 7 16; read loop
if test "$loop" = "n"
then
clear ; exit
fi
done

Reply With Quote
  #2  
Old February 7th, 2013, 04:11 PM
LKBrwn_DBA's Avatar
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2006
Posts: 751 LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level)LKBrwn_DBA User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 h 56 m 5 sec
Reputation Power: 348
Cool

Quote:
Originally Posted by prince13
can someone help me here?

. . . Etc . . .

Interesting homework...
You may need to use awk to do the hour/minute computations.

Otherwise, I personally would not use "ksh" shell to develop an application.
__________________

Reply With Quote
  #3  
Old February 9th, 2013, 06:24 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 41 m
Reputation Power: 1485
Pretty much my thought!
As a sugegstion - don't have double negative conditional statements ... if not x not y type stuff gets confusing to follow!
Also once you spot a 'fail' on input you should halt or go back to start, not continue.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Need some help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap