#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <string>
#include <math.h>
using namespace std;
string hari;
int fm(int date, int month, int year) {
int fmonth, leap;
if ((year % 100 == 0) && (year % 400 != 0))
leap = 0;
else if (year % 4 == 0)
leap = 1;
else
leap = 0;
fmonth = 3 + (2 - leap) * ((month + 2) / (2 * month)) + (5 * month + month / 9) / 2;
fmonth = fmonth % 7;
return fmonth;
}
int day_of_week(int date, int month, int year) {
int a,b,c;
int dayOfWeek;
int YY = year % 100;
int century = year / 100;
dayOfWeek = 1.25 * YY + fm(date, month, year) + date - 2 * (century % 4);
dayOfWeek = dayOfWeek % 7;
if (dayOfWeek == 0)
{ printf("Hari : Sabtu");
hari = "sabtu";
}
else
if (dayOfWeek == 1)
{ printf("Hari : Minggu");
hari = "minggu";
}
else
if (dayOfWeek == 2)
{ printf("Hari : Senin");
hari = "senin";
}
else
if (dayOfWeek == 3)
{ printf("Hari : Selasa");
hari = "selasa";
}
else
if (dayOfWeek == 4)
{ printf("Hari : Rabu");
hari = "rabu";
}
else
if (dayOfWeek == 5)
{ printf("Hari : Kamis");
hari = "kamis";
}
else
if (dayOfWeek == 6)
{ printf("Hari : Jumat");
hari = "jumat";
}
else
printf("Tanggal Tidak Ditemukan, Periksa Sekali Lagi!");
}
main()
{
char *paket;
int harga, jumlah, hargakotor;
int date, month, year, s;
float total;
string kode, diskon;
printf(" SELAMAT DATANG DI RESTORAN PAK EKO \n");
printf("---------------------------------------------------\n");
printf("| Kode | Paket | Harga | Diskon | Hari |\n");
printf("|------|---------------|---------|--------|--------|\n");
printf("| P001 | Paket Eko I | 35.000 | 10% | Senin |\n");
printf("| P002 | Paket Eko II | 45.000 | 5% | Rabu |\n");
printf("| P003 | Paket Eko III | 65.000 | 2% | Jumat |\n");
printf("---------------------------------------------------\n");
printf("\nMasukkan Tanggal (DD MM YYYY) : ");
scanf("%d%d%d", &date,&month,&year);
day_of_week(date, month, year);
printf("\n\nKode Makanan : ");
cin>>kode;
if (kode == "P001")
{ paket = "Pak Eko I";
harga = 35000;
}
else if (kode == "P002")
{ paket = "Pak Eko II";
harga = 45000;
}
else if (kode == "P003")
{ paket = "Pak Eko III";
harga = 65000;
}
else
{ paket = "Tidak Ditemukan!";
harga = 0;
}
printf("Paket : %s",paket);
printf("\nHarga : %d",harga);
printf("\nJumlah : ");
scanf("%d",&jumlah);
hargakotor = harga * jumlah;
if (kode == "P001" && hari == "senin")
{
diskon = "10%";
total = hargakotor - (hargakotor * 0.1);
}
else
if(kode == "P002" && hari == "rabu")
{
diskon = "5%";
total = hargakotor - (hargakotor * 0.05);
}
else
if (kode == "P003" && hari == "jumat")
{
diskon = "2%";
total = hargakotor - (hargakotor * 0.02);
}
else
{
diskon = "0%";
total = harga * jumlah;
}
printf("\nDiskon : %s",diskon);
printf("\n\nTotal : %g",total);
printf("\n\nTERIMA KASIH TELAH BERKUNJUNG");
printf("\n\n\n\nCopyRight (c) Hafizatul Muna : J1F115207");
getche();
}
#include <stdio.h>
#include <conio.h>
#include <string>
#include <math.h>
using namespace std;
string hari;
int fm(int date, int month, int year) {
int fmonth, leap;
if ((year % 100 == 0) && (year % 400 != 0))
leap = 0;
else if (year % 4 == 0)
leap = 1;
else
leap = 0;
fmonth = 3 + (2 - leap) * ((month + 2) / (2 * month)) + (5 * month + month / 9) / 2;
fmonth = fmonth % 7;
return fmonth;
}
int day_of_week(int date, int month, int year) {
int a,b,c;
int dayOfWeek;
int YY = year % 100;
int century = year / 100;
dayOfWeek = 1.25 * YY + fm(date, month, year) + date - 2 * (century % 4);
dayOfWeek = dayOfWeek % 7;
if (dayOfWeek == 0)
{ printf("Hari : Sabtu");
hari = "sabtu";
}
else
if (dayOfWeek == 1)
{ printf("Hari : Minggu");
hari = "minggu";
}
else
if (dayOfWeek == 2)
{ printf("Hari : Senin");
hari = "senin";
}
else
if (dayOfWeek == 3)
{ printf("Hari : Selasa");
hari = "selasa";
}
else
if (dayOfWeek == 4)
{ printf("Hari : Rabu");
hari = "rabu";
}
else
if (dayOfWeek == 5)
{ printf("Hari : Kamis");
hari = "kamis";
}
else
if (dayOfWeek == 6)
{ printf("Hari : Jumat");
hari = "jumat";
}
else
printf("Tanggal Tidak Ditemukan, Periksa Sekali Lagi!");
}
main()
{
char *paket;
int harga, jumlah, hargakotor;
int date, month, year, s;
float total;
string kode, diskon;
printf(" SELAMAT DATANG DI RESTORAN PAK EKO \n");
printf("---------------------------------------------------\n");
printf("| Kode | Paket | Harga | Diskon | Hari |\n");
printf("|------|---------------|---------|--------|--------|\n");
printf("| P001 | Paket Eko I | 35.000 | 10% | Senin |\n");
printf("| P002 | Paket Eko II | 45.000 | 5% | Rabu |\n");
printf("| P003 | Paket Eko III | 65.000 | 2% | Jumat |\n");
printf("---------------------------------------------------\n");
printf("\nMasukkan Tanggal (DD MM YYYY) : ");
scanf("%d%d%d", &date,&month,&year);
day_of_week(date, month, year);
printf("\n\nKode Makanan : ");
cin>>kode;
if (kode == "P001")
{ paket = "Pak Eko I";
harga = 35000;
}
else if (kode == "P002")
{ paket = "Pak Eko II";
harga = 45000;
}
else if (kode == "P003")
{ paket = "Pak Eko III";
harga = 65000;
}
else
{ paket = "Tidak Ditemukan!";
harga = 0;
}
printf("Paket : %s",paket);
printf("\nHarga : %d",harga);
printf("\nJumlah : ");
scanf("%d",&jumlah);
hargakotor = harga * jumlah;
if (kode == "P001" && hari == "senin")
{
diskon = "10%";
total = hargakotor - (hargakotor * 0.1);
}
else
if(kode == "P002" && hari == "rabu")
{
diskon = "5%";
total = hargakotor - (hargakotor * 0.05);
}
else
if (kode == "P003" && hari == "jumat")
{
diskon = "2%";
total = hargakotor - (hargakotor * 0.02);
}
else
{
diskon = "0%";
total = harga * jumlah;
}
printf("\nDiskon : %s",diskon);
printf("\n\nTotal : %g",total);
printf("\n\nTERIMA KASIH TELAH BERKUNJUNG");
printf("\n\n\n\nCopyRight (c) Hafizatul Muna : J1F115207");
getche();
}
0 komentar:
Posting Komentar