Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4.  
  5. void fibo(){
  6. int prev,sum;
  7. cout<<"Please input staring point of fibonacci sequence: ";
  8. cin>>sum;
  9. for(int x=0;x<6;x++){
  10. prev = sum - prev;
  11. sum += prev;
  12. cout<<prev<<" ";
  13. }
  14. }
  15.  
  16. void seats(){
  17.  
  18. string select;
  19. string seat[3][5] = {
  20. {"a","aa","ab","ac","ad"},
  21. {"b","ba","bb","bc","bd"},
  22. {"c","ca","cb","cc","cd"}
  23. };
  24. cout<<"Please input what seat you will reserve: \n\n";
  25.  
  26. for(int x=0;x<3;x++){
  27. for(int y=0;y<5;y++){
  28. cout<<"\t"<<seat[x][y]<<" ";
  29. }
  30. cout<<endl<<" \n";
  31. }
  32. cout<<"\n\n";
  33. cin>>select;
  34. for(int x=0;x<3;x++){
  35. for(int y=0;y<5;y++){
  36. if(seat[x][y] == select){
  37. seat[x][y] = "X";
  38. }cout<<"\t"<<seat[x][y]<<" ";
  39. }cout<<endl<<" \n";
  40. }
  41. cout<<"\n\nYour seat will now be reserved Thank you :) \n\n";
  42. }
  43.  
  44. void assig(){
  45. int price_arr[5],quantity_arr[5],product_arr[5],total_price=0,total_quantity=0,temp=0;
  46.  
  47. for(int x=0;x<5;x++){
  48. cout<<"Please input the prices: ";
  49. cin>>price_arr[x];
  50. cout<<"Please input the Quantity: ";
  51. cin>>quantity_arr[x];
  52. product_arr[x] = price_arr[x] * quantity_arr[x];
  53. total_price += product_arr[x];
  54. total_quantity += quantity_arr[x];
  55. }
  56. cout<<"total price is: "<<total_price;
  57. cout<<"\nTotal quantity is: "<<total_quantity;
  58.  
  59. for(int x=0;x<5;x++){
  60.  
  61. for(int y=0;y<4;y++){
  62.  
  63. if(product_arr[y] >= product_arr[y+1]){
  64.  
  65. temp = product_arr[y+1];
  66. product_arr[y+1] = product_arr[y];
  67. product_arr[y] = temp;
  68. }
  69. }
  70.  
  71. }
  72. for(int x=0;x<5;x++){
  73.  
  74. for(int y=0;y<4;y++){
  75.  
  76. if(quantity_arr[y] <= quantity_arr[y+1]){
  77.  
  78. temp = quantity_arr[y+1];
  79. quantity_arr[y+1] = quantity_arr[y];
  80. quantity_arr[y] = temp;
  81. }
  82. }
  83.  
  84. }
  85. cout<<endl;
  86. for(int x=0;x<5;x++){
  87. cout<<product_arr[x]<<" ";
  88.  
  89. }
  90. cout<<endl;
  91. for(int x=0;x<5;x++){
  92. cout<<quantity_arr[x]<<" ";
  93. }
  94. }
  95.  
  96. void mi(){
  97. int ml;
  98.  
  99. cout<<"Please enter amount of Milliliters: ";
  100.  
  101. cin>>ml;
  102.  
  103. ml = ml /500;
  104.  
  105. cout<<"the total amount of containers are: "<<ml<<endl;
  106.  
  107. }
  108.  
  109. void arr(){
  110.  
  111. int array_1 [10],x,y;
  112. cout<<"\n\tinput";
  113.  
  114. for(x=0;x<10;x++){
  115.  
  116. cin>>array_1[x];
  117.  
  118. }
  119.  
  120. for(y=0;y<10;y++){
  121.  
  122. cout<<"Square of "<<array_1[y]<<" is "<<array_1[y]*array_1[y]<<endl;
  123.  
  124. }
  125. }
  126.  
  127. main(){
  128.  
  129. int choice;
  130.  
  131. cout<<"Please input to what program you want to initiate: \n";
  132. cout<<"[1] fibonacci [2] seats [3] prices& quantity [4]Mililiters [5]Square\n\n";
  133. cin>> choice;
  134. switch(choice){
  135.  
  136. case 1:
  137. fibo();
  138.  
  139. break;
  140. case 2:
  141. seats();
  142. break;
  143.  
  144. case 3:
  145. assig();
  146. break;
  147. case 4:
  148. mi();
  149. break;
  150.  
  151. case 5:
  152. arr();
  153. break;
  154.  
  155. }
  156.  
  157.  
  158. getch();
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement