Sekarang kita akan membuat program perhitungan nilai dengan pengkondisian IF menggunakan shell script pico (Linux).
Dan kita langsung saja menuju ke syntax programnya.
Syntax programnya:
#!/bin/sh
#soal2.sh
echo "---------------------------------------------------"
echo "|PROGRAM MENGHITUNG NILAI PRAKTIKUM SISTEM OPERASI|"
echo "---------------------------------------------------"
echo -n "Masukkan Nama Mahasiswa : "
read nama
echo -n "Masukkan NIM Mahasiswa : "
read nim
echo -n "Masukkan Nilai Tugas 1 : "
read tgs1
echo -n "Masukkan Nilai Tugas 2 : "
read tgs2
echo -n "Masukkan Nilai Tugas 3 : "
read tgs3
echo -n "Masukkan Nilai Tugas Akhir : "
read ta
echo -n "Masukkan Persentase Kehadiran: "
read hadir
echo
echo "---------------------------------------------------"
echo "| DAFTAR NILAI PRAKTIKUM |"
echo "---------------------------------------------------"
echo "Nama : $nama"
echo "NIM : $nim"
echo "Nilai Tugas 1 : $tgs1"
echo "Nilai Tugas 2 : $tgs2"
echo "Nilai Tugas 3 : $tgs3"
echo "Nilai Tugas Akhir : $ta"
echo "Persentase Kehadiran: $hadir %"
ntgs1=`expr $tgs1 \* 20 / 100`
ntgs2=`expr $tgs2 \* 20 / 100`
ntgs3=`expr $tgs3 \* 20 / 100`
nta=`expr $ta \* 30 / 100`
nhadir=`expr $hadir \* 10 / 100`
total=`expr $ntgs1 + $ntgs2 + $ntgs3 + $nta + $nhadir`
if [ $total -ge 80 -a 100 -le 100 ]
then
huruf=A
bobot=4.00
elif [ $total -ge 75 -a 79 -le 79 ]
then
huruf=A-
bobot=3.67
elif [ $total -ge 70 -a 74 -le 74 ]
then
huruf=B+
bobot=3.33
elif [ $total -ge 65 -a 69 -le 69 ]
then
huruf=B
bobot=3.00
elif [ $total -ge 60 -a 64 -le 64 ]
then
huruf=B-
bobot=2.67
elif [ $total -ge 55 -a 59 -le 59 ]
then
huruf=C+
bobot=2.33
elif [ $total -ge 50 -a 54 -le 54 ]
then
huruf=C
bobot=2.00
elif [ $total -ge 40 -a 49 -le 49 ]
then
huruf=D
bobot=1.00
else
huruf=E
bobot=0.00
fi
echo "Nilai Huruf : $huruf"
echo "Bobot Nilai : $bobot"
Berikut adalah hasil outputnya:
Reblog from: https://inimateri.wordpress.com
0 komentar:
Posting Komentar