Advertisement
Xsufu

Untitled

Dec 12th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. using namespace std;
  4.  
  5. void shop();
  6.  
  7. void tablitsa();
  8.  
  9. void fibonacci();
  10.  
  11. int main(){
  12.     int menu;
  13.    
  14.     while (1){
  15.         cout << "Select of menu item: \n";
  16.         cout << " 1 - Table \n 2 - Shop \n 3 - Fibonacci numbers\n 4 - Exit\n";
  17.         cout << ">>";
  18.         cin >> menu;
  19.    
  20.         switch(menu){
  21.             case 1: system("cls"); tablitsa(); cout << "\n\n"; break;
  22.             case 2: system("cls"); shop(); cout << "\n\n"; break;
  23.             case 3: system("cls"); fibonacci(); cout << "\n\n"; break;
  24.             case 4: return 0;
  25.             default: cout << "Wrong number\n";
  26.         }
  27.     }
  28.     return 0;
  29. }
  30.  
  31. void fibonacci(){
  32.     int N;
  33.     cout << "Enter the numbers of Fibonacci numbers: ";
  34.     cin >> N;
  35.    
  36.     int F[N];
  37.    
  38.     F[0] = 0;
  39.     F[1] = 1;
  40.    
  41.     for (int i = 0; i<N; i++){
  42.         F[i+2] = F[i] + F[i+1];
  43.         cout << F[i] << " ";
  44.     }
  45. }
  46.  
  47. void tablitsa(){
  48.     int levo=0;
  49.  
  50.  
  51.     while (levo <= 1 || levo >= 9) {
  52.         cout << "Enter the left number: ";
  53.         cin >> levo;
  54.         if (levo >= 1 && levo <= 9) {
  55.             for (int i = 1; i < 11; i++) {
  56.                 cout << levo << "X" << i << " = " << levo * i << endl;
  57.             }
  58.             break;
  59.         }
  60.     }
  61. }
  62.  
  63. void shop(){
  64.     double i = 1, summ = 0, summ1 = 0, su = 0;
  65.  
  66.     while (i==1) {
  67.         cout << "Enter your summ: ";
  68.         cin >> summ;
  69.        
  70.         if (summ >= 3000) {
  71.             summ1 = summ / 100 * 20;
  72.             summ1 = summ - summ1;
  73.             cout << "You have to pay " << summ1 << endl;
  74.             su += summ1;
  75.         }
  76.         else {
  77.             if (summ >= 1000) {
  78.                 summ1 = summ / 100 * 10;
  79.                 summ1 = summ - summ1;
  80.                 cout << "You have to pay " << summ1 << endl;
  81.                 su += summ1;
  82.             }
  83.             else {
  84.                 summ1 = summ - summ1;
  85.                 cout << "You have to pay " << summ << endl;
  86.                 su += summ;
  87.             }
  88.         }
  89.        
  90.         cout << "Press '1' if someone here" << endl;
  91.         cin >> i;
  92.     }
  93.     cout << "Total on the day: " << su << endl;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement