I have here my assignment can any one teach me please

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions I have here my assignment can any one teach me please
# 1  
Old 02-23-2012
I have here my assignment can any one teach me please

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Is to compute for the discount of the two variables of TODDLER and KID

2. Relevant commands, code, scripts, algorithms:

Im newbie i dont know T_T

The group F4 and their girlfriend San Chai plans to open a
children’s play area in SM City Pines and has asked your help to create a
very simple script to compute for the bill of a customer.

The playground has 2 areas, the KIDS CORNER and the TODDLERS
PLACE. Charging for the first hour on the KIDS CORNER is pegged at PhP
60.00 and PhP 20 for the next 30 minutes. On the other hand, charging for
the first hour on the TODDLERS PLACE is pegged at PhP 40.00 and PhP 15 for
the next 30 minutes. Discounts are available for patrons who have
exceeded 5 hours. Discounts are computed this way :
5 hours to 7 hours = 10 % of total amount due
more than 7 hours to 8 hours = 12 % of total amount due
more than 8 hours = 15 % of total amount due





The script accepts the following arguments :
NAME OF CUSTOMER
TIME IN (actual time of the day the customer entered the
playground followed by either AM or PM)
TIME OUT (actual time of the day the customer moved out of
the playground followed by either AM or PM)
CUSTOMER TYPE (either TODDLER or KID)

The script would output on screen the total number of hours and
minutes the customer used the playground together with the corresponding
charge and discounts( if any). It will also APPEND on a file called
PLAY.REC all of these information.


HINT : you can use the utility expr and control structures like if, for,
case

Sample Run:
$ <your familyname>playground gepaul 10:30 AM 8:30 PM KID

OUTPUT:
===================================================
F4 and SAN CHAI PLAYGROUND
SM CITY PINES

Jan 15 2012 or system date and time

Name of Customer= gepaul
Customer Type= KID
TIME IN = 10:30 AM
TIME OUT= 8:30 PM

TIME SPENT: 10 hours 0 minutes
CHARGES: 420.00
DISCOUNT: 63.00
AMT. TO PAY: 357.00

thank you for patronage! pls. come again!


3. The attempts at a solution (include all code and scripts):

Im newbie i dont know T_T

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of California, New york, United States, Mr. Alcalde, IT222

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by stephanielana1; 02-23-2012 at 06:03 AM.. Reason: thank u thank u
# 2  
Old 02-23-2012
Understand the code first. Don't blindly copy-paste it in your assignment. And I've not included codes for error-handling. Try that yourself.

Code:
#! /bin/bash

time_diff () {
    t1=`date -d "$t_in" +%s`
    t2=`date -d "$t_out" +%s`
    t_diff=$((($t2 - $t1) / 60))
    hours=$(($t_diff / 60))
    mins=$(($t_diff % 60))
}

calc_price () {
    case $cust in
    "KID" )
        if [ $hours -gt 1 ]
        then
            if [ $mins -eq 0 ]
            then
                price=$((60 + (($hours - 1) * 2 * 20)))
            elif [ $mins -gt 0 -a $mins -le 30 ]
            then
                price=$((60 + (($hours - 1) * 2 * 20) + 20))
            elif [ $mins -gt 30 -a $mins -lt 60 ]
            then
                price=$((60 + (($hours - 1) * 2 * 20) + 40))
            fi
        else
            price=60
        fi
        ;;
    "TODDLER" )
        if [ $hours -gt 1 ]
        then
            if [ $mins -eq 0 ]
            then
                price=$((60 + (($hours - 1) * 2 * 20)))
            elif [ $mins -gt 0 -a $mins -le 30 ]
            then
                price=$((60 + (($hours - 1) * 2 * 20) + 20))
            elif [ $mins -gt 30 -a $mins -lt 60 ]
            then
                price=$((60 + (($hours - 1) * 2 * 20) + 40))
            fi
        else
            price=40
        fi
        ;;        
    esac
}

calc_discount () {
    if [ $t_diff -lt 300 ]
    then
        discount=0
    elif [ $t_diff -ge 300 -a $t_diff -le 420 ]
    then
        discount=`echo "scale=2; $price * 10 / 100" | bc`
    elif [ $t_diff -gt 420 -a $t_diff -le 480 ]
    then
        discount=`echo "scale=2; $price * 12 / 100" | bc`
    elif [ $t_diff -gt 480 ]
    then
        discount=`echo "scale=2; $price * 15 / 100" | bc`
    fi
    total=`echo "$price - $discount" | bc`
}

echo -e "Enter name: \c"
read name
echo -e "Customer Type: \c"
read cust
echo -e "Time In: \c"
read t_in
echo -e "Time Out: \c"
read t_out

time_diff
calc_price
calc_discount

echo >> PLAY.REC
echo "Name of Customer: $name" >> PLAY.REC
echo "Customer Type: $cust" >> PLAY.REC
echo "Time In: $t_in" >> PLAY.REC
echo "Time Out: $t_out" >> PLAY.REC
echo >> PLAY.REC
echo "Time Spent: $hours hours $mins minutes"
echo "Time Spent: $hours hours $mins minutes" >> PLAY.REC
echo "Charges: $price"
echo "Charges: $price" >> PLAY.REC
echo "Discount: $discount"
echo "Discount: $discount" >> PLAY.REC
echo "Amount to pay: $total"
echo "Amount to pay: $total" >> PLAY.REC
echo "-----------------------------------------------------------"
echo "-----------------------------------------------------------" >> PLAY.REC

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 02-23-2012
sir in case of i have another clarifications

sir in case of i have another clarifications, can i know your contact please...
# 4  
Old 02-23-2012
You may post your queries here. Members of this forum would help you out. And why did you delete your first post? Other members wouldn't understand the head and tail of this thread now, would they?

Moderator's Comments:
Mod Comment Original post restored
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Teach me about dynamic libraries

Hi all, new guy here, first post, with a question. My background : some linux experience, moved over to OmniOS with Napp-it front end for a home NAS server, but getting more familiar with CLU. Situation : I built APCUPSD to interface with my UPS. During the configure I specified the... (4 Replies)
Discussion started by: DerfMan
4 Replies

2. UNIX for Dummies Questions & Answers

Need a little help with assignment

Hello all im currently working on this assignment and a little stump on how to check for an argument heres the instructions: Step 4: Modify your script so that if there is an argument called TestError you display the following error message with your usage statement. TestError found Example:... (1 Reply)
Discussion started by: bsn3971
1 Replies

3. Homework & Coursework Questions

Help Assignment !! :D

Q-1 Write a shell script in Unix that lists files from your current working directory · By modification time when called with lm · By access time when called with la. By default, the script should show the listing of all the files in the current directory. Q-2 Write a shell script which... (1 Reply)
Discussion started by: Vishank Parikh
1 Replies

4. Homework & Coursework Questions

Assignment Help

1. List commands to create the directory hierarchy $HOME/a/b/c in vi to replace all occurences of TMP with tmp in lines 1 through 10 in vi to replace first occurence of CPU_file with DISK_file at line 15 2. Explain with a very simple example, usage of "ls -a" 3. What do the... (2 Replies)
Discussion started by: jessesaini
2 Replies

5. UNIX for Advanced & Expert Users

What to teach the new guy

so I have taken on the task of running a few workshops / teaching sessions. we have three new unix people, they have the basics sorted, CD, PWD, LS and such. we are looking at people who have been doing helpdesk untill two months ago. I have given them a few session: file systems, what... (2 Replies)
Discussion started by: robsonde
2 Replies

6. What is on Your Mind?

New Assignment

All Sys Administrators, With due respect I would like to know what should be BEST Things to do when LEAVING one job , and what Precaution MUST be taken while taking over new JOB?? Please Discuss in detail the STEP to be taken for both the TIME ?? (3 Replies)
Discussion started by: vakharia Mahesh
3 Replies

7. Programming

school or teach myself?

I want to learn c lenguage and am wonder if is better if i go to a school or teach myself, or there is no to much diference? Thank you (9 Replies)
Discussion started by: nobody
9 Replies
Login or Register to Ask a Question