Sponsored Content
Homework and Emergencies Homework & Coursework Questions I have here my assignment can any one teach me please Post 302601186 by balajesuri on Thursday 23rd of February 2012 04:44:03 AM
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:
 

7 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

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. 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

6. 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

7. 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
DEBCONF-MERGETEMPLATE(1)					      Debconf						  DEBCONF-MERGETEMPLATE(1)

NAME
debconf-mergetemplate - merge together multiple debconf template files SYNOPSIS
debconf-mergetemplate [options] [templates.ll ...] templates DESCRIPTION
Note: This utility is deprecated. You should switch to using po-debconf's po2debconf program. This program is useful if you have multiple debconf templates files which you want to merge together into one big file. All the specified files will be read in, merged, and output to standard output. This can be especially useful if you are dealing with translated template files. In this case, you might have your main template file, plus several other files provided by the translators. These files will have translated fields in them, and maybe the translators left in the english versions of the fields they translated, for their reference. So, you want to merge together all the translated templates files with your main templates file. Any fields that are unique to the translated files need to be added in to the correct templates, but any fields they have in common should be superseded by the fields in the main file (which might be more up-to-date). This program handles that case properly, just list each of the translated templates files, and then your main templates file last. OPTIONS
--outdated Merge in even outdated translations. The default is to drop them with a warning message. --drop-old-templates If a translation has an entire template that is not in the master file (and thus is probably an old template), drop that entire template. SEE ALSO
debconf-getlang(1) AUTHOR
Joey Hess <joeyh@debian.org> 2012-09-10 DEBCONF-MERGETEMPLATE(1)
All times are GMT -4. The time now is 05:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy