Untitled
unknown
c_cpp
3 years ago
2.6 kB
3
Indexable
/** * Di pelajarin pelan pelan ya kawan buat UAS nanti. * * - Fansa */ #include <iostream> #include <windows.h> #include <conio.h> using namespace std; struct dataProduk { char namabarang[255]; long jumlah; long harga; } structProduk[10]; void gotoxy(int x, int y) { COORD k = {x, y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), k); } int main(void) { string namasuplier; string alamatsuplier; char namabarang[255]; char pil; long bayar; long tharga; long tbayar; long tdiskon; long tgrand; long tkembali; float diskon; int i, j = 0; pil = 'Y'; gotoxy(2, 1); cout << "Nama Suplier: "; getline(cin, namasuplier); gotoxy(2, 2); cout << "Alamat Suplier: "; getline(cin, alamatsuplier); while (pil == 'Y' || pil == 'y') { system("cls"); gotoxy(2, 1); cout << "Nama Barang: "; cin >> structProduk[i].namabarang; gotoxy(2, 2); cout << "Jumlah: "; cin >> structProduk[i].jumlah; gotoxy(2, 3); cout << "Harga: "; cin >> structProduk[i].harga; gotoxy(2, 4); cout << "Input Data Lagi? Tekan Y: "; pil = getch(); i++; if (i >= 5) break; } gotoxy(2, 5); cout << "Bayar: "; cin >> bayar; system("cls"); gotoxy(2, 1); cout << "Nama Suplier: " << namasuplier; gotoxy(2, 2); cout << "Alamat Suplier: " << alamatsuplier; gotoxy(2, 3); cout << "_________________________________________________________"; gotoxy(2, 5); cout << "No"; gotoxy(5, 5); cout << "Nama Barang"; gotoxy(20, 5); cout << "Jumlah"; gotoxy(28, 5); cout << "Harga"; gotoxy(35, 5); cout << "Total"; gotoxy(43, 5); cout << "Diskon"; gotoxy(52, 5); cout << "Bayar"; gotoxy(2, 6); cout << "_________________________________________________________"; for (j = 0; j < i; j++) { tharga = structProduk[j].harga * structProduk[j].jumlah; diskon = 0; if (tharga > 10000) diskon = 10; if (tharga > 5000 && tharga < 10000) diskon = 5; tdiskon = tharga * diskon / 100; tbayar = tharga - (tharga * diskon / 100); tgrand += tbayar; gotoxy(2, 7 + j); cout << j + 1; gotoxy(5, 7 + j); cout << structProduk[j].namabarang; gotoxy(20, 7 + j); cout << structProduk[j].jumlah; gotoxy(28, 7 + j); cout << structProduk[j].harga; gotoxy(35, 7 + j); cout << tharga; gotoxy(43, 7 + j); cout << tdiskon; gotoxy(52, 7 + j); cout << tbayar; } tkembali = bayar - tgrand; gotoxy(35, 9 + i); cout << "Grand Total: " << tgrand; gotoxy(35, 10 + i); cout << "Bayar: " << bayar; gotoxy(35, 11 + i); cout << "Kembali: " << tkembali; }
Editor is loading...