Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "resistors.h"
  2.  
  3. void computeResistance( istream& in, ostream& out )
  4.  
  5. {
  6.  
  7.     double resistance;
  8.     double R1;
  9.     double R2;
  10.     double R3;
  11.     in >> R1;
  12.     in >> R2;
  13.     in >> R3;
  14.    
  15.     while( !in.fail() )
  16.  
  17.     {
  18.         resistance = 1/(1/R1+1/R2+1/R3);
  19.    
  20.         if (R1 == 0 || R2 == 0 || R3 == 0)
  21.         {
  22.             out << "--error--" << endl;
  23.             return;
  24.         }
  25.        
  26.         out << resistance << endl;
  27.        
  28.         in >> R1;
  29.         in >> R2;
  30.         in >> R3;
  31.        
  32.     }
  33.    
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement