0% found this document useful (0 votes)
10 views

Contoh Ifelseifint - CPP

The document is a C++ program that calculates purchase totals and discounts for different items. It prompts the user to enter an item code, then displays the item name and price. It asks for the quantity and calculates the total. Different discount rates are applied based on the total amount, and the final total to pay is displayed.

Uploaded by

Faizul Haizal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Contoh Ifelseifint - CPP

The document is a C++ program that calculates purchase totals and discounts for different items. It prompts the user to enter an item code, then displays the item name and price. It asks for the quantity and calculates the total. Different discount rates are applied based on the total amount, and the final total to pay is displayed.

Uploaded by

Faizul Haizal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <string>
using namespace std;
int main()
{
int kb, jb, th;
int dis, tb;
printf("Data Barang : 22326=Baju | 22328=Celana |
22256=Peci");
printf("\nMasukkan Kode Barang : ");
scanf("%i",&kb);
if(kb==22326)
{
char nb[25]="Baju";
int hb=75000;
printf("Nama Barang : %s\n", &nb);
printf("Harga Barang : %i\n", hb);
printf("Masukkan Jumlah Barang : ");
scanf("%i",&jb);
th=jb*hb;
printf("Total Harga : %i\n", th);
if(th>300000)
{
dis=th*(0.15);
printf("Diskon : %i\n",
dis);
tb=th-dis;
printf("Total Bayar : %i\n",
tb);
}
else if(th>20000)
{
dis=th*(0.10);
printf("Diskon : %i\n",
dis);
tb=th-dis;
printf("Total Bayar : %i\n",
tb);
}
else
{
dis=th*(0.08);
printf("Diskon : %i\n",
dis);
tb=th-dis;
printf("Total Bayar : %i\n",
tb);
}

}
else if(kb==22328)
{
char nb[25]="Celana";
int hb=250000;
printf("Nama Barang : %s\n", &nb);
printf("Harga Barang : %i\n", hb);
printf("Masukkan Jumlah Barang : ");
scanf("%i",&jb);
th=jb*hb;
printf("Total Harga : %i\n", th);
if(th
dis=th*(0.08);
printf("Diskon : %i\n", dis);
tb=th-dis;
printf("Total Bayar : %i\n", tb);
}
else if(kb==22256)
{
char nb[25]="Peci";
int hb=50000;
printf("Nama Barang : %s\n", &nb);
printf("Harga Barang : %i\n", hb);
printf("Masukkan Jumlah Barang : ");
scanf("%i",&jb);
th=jb*hb;
printf("Total Harga : %i\n", th);
dis=th*(0.08);
printf("Diskon : %i\n", dis);
tb=th-dis;
printf("Total Bayar : %i\n", tb);
}
else
{
printf("\nKode Tersebut Tidak Ada");
}
return 0;
}

You might also like