-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathamt4-bc.sh
49 lines (49 loc) · 1.2 KB
/
amt4-bc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#/!/bin/bash
echo "This is Abbreviated Mental Test-4 (AMT4) Calculator"
echo "======================================================="
echo "What is your age? [0-1]"
while :; do
read A1
if [[ -z $A1 ]]; then
echo "Entry cannot be empty"
elif [[ $A1 -ge 0 && $A1 -le 1 ]]; then
break
else
echo "Value is out of range. Please, enter a valid number"
fi
done
echo "What is the year? [0-1]"
while :; do
read A4
if [[ -z $A4 ]]; then
echo "Entry cannot be empty"
elif [[ $A4 -ge 0 && $A4 -le 1 ]]; then
break
else
echo "Value is out of range. Please, enter a valid number"
fi
done
echo "What is the name of this place? [0-1]"
while :; do
read A5
if [[ -z $A5 ]]; then
echo "Entry cannot be empty"
elif [[ $A5 -ge 0 && $A5 -le 1 ]]; then
break
else
echo "Value is out of range. Please, enter a valid number"
fi
done
echo "What is your date of birth (day & month)? [0-1]"
while :; do
read A7
if [[ -z $A7 ]]; then
echo "Entry cannot be empty"
elif [[ $A7 -ge 0 && $A7 -le 1 ]]; then
break
else
echo "Value is out of range. Please, enter a valid number"
fi
done
ans=$(echo $A1 + $A4 + $A5 + $A7 | bc)
echo "The total AMT4 score is" $ans"/4"