irwan94

array tinggal copas nak BSI

Nov 18th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. #include <iostream>
  2. #include "conio.h"
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6. int main()
  7. {
  8. int x = 0 , qty, a, b[10], c, d, harga[10], kali[10], total[10] = { 0 };
  9. char code, jenis[10][10];
  10. char header[3][10] = { "Kode", "Jenis", "Harga" };
  11. char header2[3][3][3][10] = { { { "D", "P", "S" }, { "DADA", "PAHA", "SAYAP" }, { "2500", "2000", "1500" } } };
  12. cout << "Gerobak Fried chicken"<<endl;
  13. cout << "-----------------------"<<endl;
  14. for (int a0 = 0; a0 <= 2; a0++)
  15. {
  16. cout << setiosflags(ios::left) << setw(9) << header[a0];
  17. }
  18. cout << endl;
  19. for (int b0 = 0; b0 <= 2; b0++)
  20. {
  21.  
  22.  
  23. for (int c0 = 0; c0 <= 2; c0++)
  24. {
  25. for (int d0 = 0; d0 <= 2; d0++)
  26. {
  27.  
  28. cout << setiosflags(ios::left) << setw(3) << header2[d0][c0][b0];
  29.  
  30.  
  31. }
  32.  
  33. }
  34.  
  35. cout << endl;
  36. }
  37.  
  38.  
  39. cout << "-----------------------"<<endl;
  40. cout << "Banyak Jenis:"; cin >> qty;
  41. for (a = 1; a <= qty; a++)
  42. {
  43. cout << "Jenis KE:" << a<<endl;
  44. cout << "Kode Potong[D/P/S]:"; cin>>code;
  45. cout << "Banyak Potong:"; cin >> b[a];
  46. switch (code)
  47. {
  48. case 'D':
  49. case 'd':
  50. strcpy_s(jenis[a], "Dada");
  51. harga[a] = 2500;
  52. break;
  53. case 'P':
  54. case 'p':
  55. strcpy_s(jenis[a], "Paha");
  56. harga[a] = 2000;
  57. break;
  58. case 'S':
  59. case 's':
  60. strcpy_s(jenis[a], "Sayap");
  61. harga[a] = 1500;
  62.  
  63. }
  64.  
  65. kali[a] = b[a] * harga[a];
  66. total[x] = total[x] + harga[a] * b[a];
  67. }
  68. system("cls");
  69.  
  70. cout << "\t\tGerobak Fried chicken" << endl;
  71. cout << "--------------------------------------------" << endl;
  72. char koplok[5][10] = { "No.", "Jenis", "Harga", "Banyak", "Jumlah" };
  73. char koplok2[4][10] = { "Potong", "Satuan", "Potong", "Harga" };
  74. for (int ab = 0; ab <= 4; ab++)
  75. {
  76. cout << setiosflags(ios::left) << setw(9) << koplok[ab];
  77. }
  78. cout << endl;
  79. for (int abc = 0; abc <= 3; abc++)
  80. {
  81. if (abc < 1)
  82. {
  83. cout << setiosflags(ios::right) << setw(15) << koplok2[abc];
  84. }
  85. else
  86. cout << setiosflags(ios::right) << setw(9) << koplok2[abc];
  87.  
  88.  
  89. }
  90. cout << endl;
  91. for (a = 1; a <= qty; a++)
  92. {
  93.  
  94. cout << a;
  95. cout << setiosflags(ios::right) << setw(12) << jenis[a];
  96. cout << setiosflags(ios::right) << setw(9) << harga[a];
  97. cout << setiosflags(ios::right) << setw(7) << b[a];
  98. cout << setiosflags(ios::right) << setw(13) << kali[a];
  99.  
  100. cout << endl;
  101. }
  102. cout << "--------------------------------------------" << endl;
  103. cout << setiosflags(ios::right) << setw(35) << "Jumlah Bayar:"<<total[x];
  104.  
  105.  
  106.  
  107. _getch();
  108. return(0);
  109. }
  110.  
  111. //coded by irwan
Advertisement
Add Comment
Please, Sign In to add comment