Skip to content

Instantly share code, notes, and snippets.

@bentinata
Created October 2, 2015 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bentinata/b9edf6d7057735fbfb20 to your computer and use it in GitHub Desktop.
Save bentinata/b9edf6d7057735fbfb20 to your computer and use it in GitHub Desktop.
////////////////////////////////////////////////////////////////////////////////
// Saya Benget Nata bersumpah tidak melakukan kecurangan, yaitu: //
// 1. Mengetikkan kode program dengan melihat kode program teman. //
// 2. Mengetikkan kode program berdasarkan petunjuk oleh teman. //
// 3. Mengumpulkan kode program milik teman. //
// 4. Memberikan mengetikkan terkait kode program yang dikumpulkan. //
// 5. Memiliki alur program yang sama persis dengan teman. //
// Jika saya melakukan kecurangan maka Tuhan adalah saksi saya, //
// dan saya bersedia menerima hukuman-Nya. //
////////////////////////////////////////////////////////////////////////////////
/** SWEETWARE LICENSE version 0.1.1
* As long as you retain this notice
* you can do whatever you want with this stuff.
* If we meet some day, and you think this stuff is worth it,
* you can buy me sweets in return. Benget Nata
*/
#include <stdio.h>
int main() {
int day, in, out, moni, starting_hourly, continous_hourly;
float tax;
char packet;
char dayname[7][5] = ["senin", "selasa", "rabu", "kamis", "jumat", "sabtu", "minggu"];
scanf("%d", &day);
// Normal day: 1, 2, 3, 4, 5. Tax = 100%.
// Weekend day: 6, 7. Tax = 125%.
if (day <= 5) {
tax = 1;
}
else if (day > 5) {
tax = 1.25;
}
scanf(" %c", &packet);
scanf("%d", &in);
scanf("%d", &out);
// If in hour is bigger than out hour (e.g. in = 22, out = 4),
// out hour is added by 24 (e.g. in = 22, out = 28).
// Therefore, the difference is still positive number.
if (in > out) {
// Reusing variables so compiled program is smaller.
in = (out + 24) - in;
}
// Explicit condition is a good practice.
else if (in < out) {
in = out - in;
}
scanf("%d", &moni);
if (packet == 'a') {
char[] packetname = "kelabu";
out = 2;
starting_hourly = 1500;
continous_hourly = 500;
}
else if (packet == 'b') {
char[] packetname = "ceria";
out = 1;
starting_hourly = 3000;
continous_hourly = 1000;
}
if (in > out) {
moni -= ((in - out) * continous_hourly + (out) * starting_hourly) * tax;
}
else if (in < out) {
moni -= starting_hourly * in * tax;
}
// I got string in me.
// ___+___
// : : :
// : o :
// :_/|\/
// /\
// ejm96 / /
printf("%s %s\n", dayname[day+1], packetname);
if (moni >= 0) {
printf("%d\n", moni);
} else if (moni < 0) {
printf("tidak valid\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment