kestutis

2 lygis | 1 pamoka | Mobilusis telefonas išsimokėtinai

Nov 29th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. //Telefono issimokejimas
  2. #include <fstream>
  3. #include <string>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7. const char CDfv[] = "Duomenys.txt";
  8. const char CRfv[] = "Rezultatai.txt";
  9.  
  10. //Funkcijų aprasai
  11. double Pabrangimas(double K, double N, int L, double M);
  12. double PabrangimasPr(double K, double P);
  13.  
  14. int main() {
  15.     double K, N, M;         //Telefono kaina, menesine palukanu norma
  16.                               //ir sutarties mokestis
  17.     int L;                   //Issimokejimo laikotarpis
  18.  
  19.     ifstream fd(CDfv);
  20.     fd >> K >> N >> L >> M;
  21.     fd.close();
  22.  
  23.     ofstream fr(CRfv);
  24.     double Pr = Pabrangimas(K, N, L, M);
  25.     fr << setprecision(2) << PabrangimasPr(K, Pr) << endl ;
  26.     fr.close();
  27.     return 0;
  28. }
  29.  
  30. //Funkcija, suskaiciuojanti metini pabrangima procentais
  31. double PabrangimasPr(double K, double P) {
  32.     return P / K * 100;
  33. }
  34.  
  35. //Funkcija suskaiciuojanti bendra pabrangima
  36. double Pabrangimas(double K, double N, int L, double M) {
  37.     double men = K / L; //per viena menesi grazinama telefono kainos dalis
  38.     double suma = 0;
  39.     for (int i = 0; i < L; i++){
  40.             suma += (K - (men * i)) * N / 100;
  41.     }
  42.     return suma + M;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment