0% found this document useful (0 votes)
14 views2 pages

Uas 1

The document contains code for a program that collects student data including student ID, city of origin, school code, and test scores in three subjects. It then calculates the total score, identifies the city and school for each student, and outputs the data in a table.

Uploaded by

hajimex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Uas 1

The document contains code for a program that collects student data including student ID, city of origin, school code, and test scores in three subjects. It then calculates the total score, identifies the city and school for each student, and outputs the data in a table.

Uploaded by

hajimex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>
#include <stdlib.h>
#include <string.h>
#define MAKS 20
main()
{
char nisn[20];
char kota[20];
char kode[20];
float matematika;
float bind;
float bing;
float total;
int i=0,sudah_benar,jml_lulus,jml_tidak_lulus,jml;
float nilai_max;
char lagi;
do
{
printf("NISN
: ");
scanf ("%s",&nisn);
printf ("Matematika
: ");
scanf ("%f",&matematika);
printf ("Bahasa Indonesia
: ");
scanf ("%f", &bind);
printf ("Bahasa Inggis
: ");
scanf ("%f", &bing);
printf ("\n");
i++;
printf ("Tambah data lagi [Y/T] ?");
do
{
lagi = getchar ();
sudah_benar= (lagi=='Y') || (lagi=='y')||
(lagi=='T')|| (lagi=='t');
}
while (!sudah_benar);
printf ("\n");
} while (lagi == 'Y' || lagi=='y');
jml= i;
if (nisn[0]=='0' &&nisn[1]=='1')
strcpy(kota, "Surabaya");
else if (nisn[0]=='0' &&nisn[1]=='2')
strcpy(kota, "Malang");
else if (nisn[0]=='0'&&nisn[1]=='3')
strcpy(kota, "Sidoarjo");
else if (nisn[0]=='0' &&nisn[1]=='4')
strcpy(kota, "Banyuwangi");
kode=nisn[2][3][4];
printf ("===Ujian Nasional===\n");
printf("|------------|------------|-------------|---------------|------------|\n");
printf ("|
NISN
| TOTAL
| KOTA ASAL | KODE SEKOLAH |
STATUS
|\n");
printf ("|------------|------------|-------------|---------------|----------

---|\n");
for (i=0; i<jml; i++)
{
printf ("| %10s | %10.2f | %11s | %13s | %11s |\n",nisn,matematika+bind+bing
,kota,kode);
}
printf ("|------------|------------|-------------|---------------|------------|\n");
/*if (<=100000)
diskon=0.01;
{if (A>=100000)
diskon=0.05;
{if (A>=500000)
diskon=0.1;
}}
B=diskon*A;
printf("diskon
: %.2f\n",B);
pembelian=A-diskon;
printf("pembelian
: %.2f\n",pembelian);
printf("anda member ? (y/n)\n");
member=getch();
if (member=='y'||member=='Y')
{
C=pembelian*C;
printf("diskon member : %.2f\n",C);
total_bayar=pembelian-C;
printf("total biaya : %.2f\n",total_bayar);
}
else
printf("total biaya : %.2f\n",pembelian);*/
}

You might also like