Facebook
From Gruff Hedgehog, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 244
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. float srednia,wymarzona;
  5. int ile,ocena,suma,sumawag,waga;
  6. int main()
  7. {
  8.     cout << "Ile masz ocen z przedmiotu " << endl;
  9.     cin>>ile;
  10.     for(int i=1; i<=ile; i++)
  11.     {
  12.         cout<<"Jaka "<< i << " ocena ";
  13.         cin>>ocena;
  14.         cout<<"Jaka "<< i << " waga ";
  15.         cin>>waga;
  16.         sumawag=waga+sumawag;
  17.         suma=suma+(ocena*waga);
  18.     }
  19.     srednia=float(suma)/float(sumawag);
  20.  
  21.     cout<<setprecision(3)<<srednia<<endl;
  22.  
  23.     if(srednia>=5.76)
  24.     {
  25.         cout<<"Celujacy"<<endl;
  26.     }
  27.     else
  28.     {
  29.         if(srednia>=4.76)
  30.         {
  31.         cout<<"Bardzo dobry"<<endl;
  32.         }
  33.         else
  34.         {
  35.             if(srednia>=3.76)
  36.             {
  37.             cout<<"Dobry"<<endl;
  38.             }
  39.             else
  40.             {
  41.                 if(srednia>=2.76)
  42.                 {
  43.                 cout<<"Dostateczny"<<endl;
  44.                 }
  45.                 else
  46.                 {
  47.                     if(srednia>=1.76)
  48.                     {
  49.                     cout<<"Dopuszczajacy"<<endl;
  50.                     }
  51.                 }
  52.             }
  53.         }
  54.     }
  55.     cout<<"Co bys chcial dostac na koniec? ";
  56.     cin>>wymarzona;
  57.     switch(int (wymarzona))
  58.     {
  59.         case 2:
  60.             wymarzona=1.76;
  61.             break;
  62.         case 3:
  63.             wymarzona=2.76;
  64.             break;
  65.         case 4:
  66.             wymarzona=3.76;
  67.             break;
  68.         case 5:
  69.             wymarzona=4.76;
  70.             break;
  71.         case 6:
  72.             wymarzona=5.76;
  73.             break;
  74.         default:
  75.             cout<<"Blad"<<endl;
  76.  
  77.     }
  78.     for(int o=6; o>=2; o--)
  79.     {
  80.         if(wymarzona<=o)
  81.         {
  82.             for(int w=1; srednia<=wymarzona; w++)
  83.             {
  84.             srednia=float(suma+(o*w))/float(sumawag+w);
  85.             if(srednia>=wymarzona)
  86.                 {
  87.                 cout<<"Musisz dostac "<<o<<" z waga "<< w <<endl;
  88.                 }
  89.             }
  90.         }
  91.     srednia=0;
  92.     }
  93.  
  94.     return 0;
  95. }
  96.