#include
#include
#include
COORD coord={0,0};
void gotoxy (int x, int y)
{
coord.X = x; coord.Y = y; // X and Y coordinates
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
int main()
{
char tanggal[2];
int pilihan;
int total;
int kode;
char text[50];
char namapenyewa[50];
char alamat[50];
int lamasewa;
char telepon[25];
char merk [10];
char *line = { "\n---------------------------------------------- \n" };
char *merkinput = {"merk laptop:"};
char *tanggalinput = {"\ntanggal sewa : "};
char *namapenyewainput = {"\nNama: " };
char *alamatinput = { "Alamat: " };
char *teleponinput = {"no.telepon: "};
/*char *telepon = { "no.telepon: " };*/
char *newline = "\n";
FILE *file_ptr;
file_ptr = fopen("datapenyewa.dat", "a");
if(file_ptr != NULL)
{
system("cls");
system("color D9");
pilihan:
printf("\t\tDibuat oleh:\n");
printf("\t LITA LIKMALATRI\n");
printf("\t\t5302411238\n");
printf(" Pendidikan Teknik Informatika dan Komputer\n");
printf("\tUniversitas Negeri Semarang\n");
printf("\t\t 2011\n\n");
printf(" =================================\n");
printf(" # Selamat Datang di Lepi Laptop #\n");
printf(" =================================\n");
printf(" jasa penyewaan laptop masa kini\n");
printf(" pertama dan terpercaya\n");
printf("===============================================\n\n\n");
printf(" \t\tMenu Utama:\n\n");
printf("\t\t1.sewa\n\n");
printf("\t\t2.cek daftar sewa\n\n");
printf("\t\t3.keluar\n\n");
printf(newline);
printf("Masukkan pilihan: ");
scanf("%d", &pilihan);
fclose(file_ptr);
}
if(pilihan==1)
{
file_ptr = fopen("datapenyewa.dat", "a");
if(file_ptr != NULL)
{
system("cls");
system("color E5");
printf("\t======================================\n");
printf("\tkode\t merk_laptop\t harga_sewa\n");
printf("\t======================================\n");
printf("\t 1\t toshiba \t Rp20000/hari\n");
printf("\t 2\t asus \t Rp18000/hari\n");
printf("\t 3\t acer \t Rp17000/hari\n");
printf("\t 4\t hp \t Rp15000/hari\n");
printf("\t 5\t compaq \t Rp15000/hari\n\n");
printf(newline);
printf("masukkan kode laptop: ");
scanf("%d",&kode);
{
if(kode==1)
{
printf("merk laptop : toshiba\n");
printf("lama sewa : hari");
gotoxy(12,12);
scanf("%d",&lamasewa);
total = lamasewa * 20000;
printf("total harga sewa = Rp %d",total);
goto lanjutan;
}
else if(kode==2)
{ printf("merk laptop : asus \n");
printf("lama sewa : hari");
gotoxy(12,12);
scanf("%d",&lamasewa);
total =lamasewa * 18000;
printf("total harga sewa = Rp %d",total);
goto lanjutan;
}
else if(kode==3)
{
printf("merk laptop : acer\n");
fputs(merk,file_ptr);
printf("lama sewa : hari");
gotoxy(12,12);
scanf("%d",&lamasewa);
total =lamasewa * 17000;
printf("total harga sewa = Rp %d",total);
goto lanjutan;
}
else if(kode==4)
{ printf("merk laptop : hp\n");
printf("lama sewa : hari");
gotoxy(12,12);
scanf("%d",&lamasewa);
total =lamasewa * 15000;
printf("total harga sewa = Rp %d",total);
goto lanjutan;
}
else if(kode==5)
{ printf("merk laptop : compaq\n");
printf("lama sewa : hari");
gotoxy(12,12);
scanf("%d",&lamasewa);
total =lamasewa * 15000;
printf("total harga sewa = Rp %d\n\n",total);
goto lanjutan;
}
}
lanjutan:
printf("\n\t\tmasukkan Data penyewa!!!\n");
printf("Masukkan nama : ");
fputs(namapenyewainput, file_ptr);
fflush(stdin);
fgets(namapenyewa, 50, stdin);
fputs(namapenyewa, file_ptr);
printf("Masukkan alamat: ");
fputs(alamatinput, file_ptr);
fflush(stdin);
fgets(alamat, 50, stdin);
fputs(alamat, file_ptr);
printf("Masukkan no.telepon: ");
fputs(teleponinput, file_ptr);
fflush(stdin);
fgets(telepon, 25, stdin);
fputs(telepon, file_ptr);
printf("masukkan merk laptop: ");
fputs(merkinput, file_ptr);
fflush(stdin);
fgets(merk,10,stdin);
fputs(merk,file_ptr);
printf("masukkan tanggal sewa :");
fputs(tanggalinput, file_ptr);
fflush(stdin);
fgets(tanggal,2,stdin);
fputs(tanggal,file_ptr);
printf("masukkan tanggal pengembalian: ");
fputs(tanggalinput,file_ptr);
fflush(stdin);
fgets(tanggal,2,stdin);
fputs(tanggal,file_ptr);
printf(line);
fputs(line, file_ptr);
fflush(stdin);
goto pilihan;
}
fclose(file_ptr);
}
else if(pilihan == 2)
{
file_ptr = fopen("datapenyewa.dat", "r");
if(file_ptr != NULL)
{
system("cls");
system("color 75");
printf("Data penyewa: \n\n\n");
while(fgets(text, 50, file_ptr) != NULL)
{
printf("%s", text);
printf(newline);
}
fclose(file_ptr);
}
}
else if(pilihan==3)
{system("cls");
system("color 25");
printf("\n\n\t\t\t*terimakasih telah mempercayai kami*\n\n");
exit(1);
}
else
{
printf("\n\t\tinput data salah.silahkan mencoba lagi!!!\n\n");
}
return 0;
}
Selamat mencoba!
Tidak ada komentar:
Posting Komentar