AnAriyan

preMidxmSolution

Feb 27th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uvall#include<iostream>
  2. using namespace std;
  3.  
  4. class PreMidXam {
  5.  
  6.  
  7. private:
  8.  
  9. int num1,G=0,S=0;
  10. char coin;
  11. int n,sum=0;
  12. int num3,rem=0,div=0,multi=0;
  13. int num4,ram=0,rev=0,counter=0;
  14. float s=0,avg;
  15. int N;
  16.  
  17. public:
  18.  
  19.  
  20. void number1() {
  21. cout<<"Enter how many coin u want to calculate : ";
  22. cin>>num1;
  23. for(int i=1; i<=num1; i++)
  24. {cout<<"Enter coin : ";
  25.    cin>>coin;
  26.  
  27.     while(coin!='G' && coin!='S')
  28.    {
  29.        cout<<"Enter valid coin : ";
  30.         cin>>coin;
  31.     }
  32.  
  33.  
  34.  
  35.     if (coin=='G'){
  36.         G++;
  37.     }
  38.     if(coin=='S')
  39.     {
  40.         S++;
  41.     }
  42.  
  43. }
  44. cout<<"Gold : "<<G<<endl;
  45. cout<<"Silver : "<<S<<endl;
  46.  
  47.  
  48.  
  49. }
  50. void number2() {
  51.  
  52. cout<<"Enter a positive num : ";
  53. cin>>n;
  54.  
  55. for(int i=1; i<n/2;i++)
  56. {
  57. sum+=i;
  58. }
  59. for(int i=n/2 ;i<=n; i++)
  60. {
  61. sum=sum+i;
  62. }
  63. cout<<"The Sum of the First "<<n<<" integers is "<<sum<<endl;
  64.  
  65.  
  66. }
  67.  
  68. void number3 (){
  69.    cout<<"Enter a Number for check multiple output : ";
  70.    cin>>num3;
  71.    for(int i=1; i<=100; i++)
  72.   {
  73.      rem=0;
  74.      div=0;
  75.      rem=i%10;
  76.      div=i/10;
  77.      multi=rem*div;
  78.      if(multi==num3)
  79.      {
  80.          cout<<i<<endl;
  81.          break;
  82.  
  83.      }
  84.      if(i>=100)  {
  85.              if(multi==num3)
  86.       {
  87.           cout<<i<<endl;
  88.          break;
  89.  
  90.      }
  91.      else cout<<"No Multiple output "<<endl;;
  92.  
  93.  
  94.      }
  95.   }
  96.  
  97. }
  98.  
  99. void number4 (){
  100. cout<<"Enter a Number for Reverse : ";
  101. cin>>num4;
  102.  
  103. while(num4!=0)
  104. {
  105.  
  106.     ram=num4%10;
  107.     num4=num4/10;
  108.     counter++;
  109.     rev=rev*10+ram;
  110.     s=s+ram;
  111. }
  112. avg=s/counter;
  113.  
  114. cout<<"Reverse : "<<rev<<endl;
  115. cout<<"Average : "<<avg <<endl;
  116. }
  117. void number5() {
  118.  
  119. cout<<"Enter Pattern Size : ";
  120. cin>>N;
  121.  
  122. for(int i=1; i<=N; i++)
  123. {
  124.  for(int j=1; j<=i; j++)
  125.  {
  126.      cout<<i*j<<" ";
  127.  }
  128.  cout<<endl;
  129.  
  130.  
  131.  
  132. }
  133.  
  134. }
  135.  
  136.  
  137.  
  138.  
  139. };
  140.  
  141. int main () {
  142.  
  143. PreMidXam obj;
  144. obj.number1();
  145. cout<<endl;
  146. obj.number2();
  147. cout<<endl;
  148. obj.number3();
  149. cout<<endl;
  150. obj.number4();
  151. cout<<endl;
  152. obj.number5();
  153. cout<<endl;
  154.  
  155. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment