Читаем 100 Shell Programs in Unix полностью

)  If a person’s health is excellent and the person is between 25 and 35 years of age and lives in a city and is a male then Premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs.

(

ii

)  If a person satisfies all the above conditions except that the sex is female then the premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.

(

iii

) if a person’s health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then the Premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000.

(

iv

)  In all other cases the person is not insured.

Write a program to output whether the person should be insured or not, his/her Premium rate and maximum amount for which he/she can be insured.

$vi prg100

clear

echo Enter age of the person

read age

echo Enter where he lives (city or village)?

ead liv

echo Enter gender (male or female)?

read gender

echo Enter health (poor or excellent)?

read health

echo

if [ $age -ge 25 -a $age -le 35 -a $liv = ‘city’ -a $gender = ‘male’ -a $health = excellent]

then

echo The person should be insured

echo Premium is Rs.4 per thousand

echo Policy amount cannot exceed Rs.2 lakh

elif [ $age -ge 25 -a $age -le 35 -a $liv = ‘city’ -a $gender = ‘female’ -a $health  =   ‘excellent’ ]

then

echo The person should be insured

echo Premium is Rs.3 per thousand

echo Policy amount cannot exceed Rs.1 lakh

elif [ $age -ge 25 -a $age -le 35 -a $liv = ‘village’ -a $gender = ‘male’ -a $health = ‘poor’]

then

echo The person should be insured

echo Premium is Rs.6 per thousand

echo Policy amount cannot exceed Rs.10,000

else

echo The person should not be insured

fi

Sample Run

$sh prg100

Enter age of the person

26

Enter where he lives (city or village)?

city

Enter gender (male or female)?

male

Enter health (poor or excellent)?

excellent

The person should be insured

Premium is Rs.4 per thousand

Policy amount cannot exceed Rs.2 lakh

$sh prg100

Enter age of the person

33

Enter where he lives (city or village)?

city

Enter gender (male or female)?

female

Enter health (poor or excellent)?

excellent

The person should be insured

Premium is Rs.3 per thousand

Policy amount cannot exceed Rs.1 lakh

$sh prg100

Enter age of the person

3

Enter where he lives (city or village)?

village

Enter gender (male or female)?

male

Enter health (poor or excellent)?

poor

The person should be insured

Premium is Rs.6 per thousand

Policy amount cannot exceed Rs.10,000

$sh prg100

Enter age of the person

24

Enter where he lives (city or village)?

village

Enter gender (male or female)?

male

Enter health (poor or excellent)?

poor

The person should not be insured

Table of Contents

Front Cover

Title Page

Copyright

Contents

Preface

Acknowledgement

Part I: Introduction

Chapter I. An Overview

Chapter II. Salient Features of Unix

Chapter III. Hardware Requirements for Unix

Chapter IV. Getting Started

Chapter V. Unix Architecture

Chapter VI. Unix Basic Commands

Chapter VII. Portability with C

Part II: Programs

Похожие книги

Книги не найдены