SHARE
TWEET

Latihan UAS

a guest Jan 15th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #define maks 100
  4. struct pasien
  5. {
  6.     char np[100];
  7.     float ba;
  8.     float bd;
  9.     float bo;
  10.     float tb;
  11. };
  12. float hitung(float,float,float);
  13. main ()
  14. {
  15.     struct pasien data[maks];
  16.     int i,n,k;
  17.     printf("Masukkan Jumlah Pasien = ");
  18.     scanf("%d",&n);
  19.     fflush(stdin);
  20.     for(i=0;i<n;i++)
  21.     {
  22.         printf("Masukkan Nama Pasien ke - %d : ",i+1);
  23.         gets(data[i].np);
  24.         printf("Masukkan Jenis Dokter \n [1]Spesialis/n[2]Umum = ");
  25.         scanf("%d",&k);
  26.         if(k==1)
  27.         {
  28.             data[i].bd=150000;
  29.         }
  30.         else
  31.         {
  32.  
  33.             data[i].bd=100000;
  34.         }
  35.         printf("Masukkan Biaya Obat = ");
  36.         scanf("%f",&data[i].bo);
  37.         data[i].ba=20000;
  38.         data[i].tb=hitung(data[i].ba,data[i].bd,data[i].bo);
  39.     }
  40.     system("cls");
  41.     for(i=0;i<n;i++)
  42.     {
  43.         printf("Nama : %s \n",data[i].np);
  44.         printf("Total Biaya = %2.f ",data[i].tb);
  45.     }
  46.     getch();
  47. }
  48.  
  49. float hitung(float x,float y,float z)
  50. {
  51.     char ap;
  52.     float biaya,potongan=0;
  53.     printf("Ada Potongan ? [y/t] : ");
  54.     scanf("%s",&ap);
  55.     biaya=x+y+z;
  56.     if(ap=='y')
  57.     {
  58.         potongan=z*0.1;
  59.     }
  60.     biaya=biaya-potongan;
  61.     return biaya;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top