

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


1 #include
68 for(int i = 0 ; i < NumR; i++) 69 Hold += 1. 0 F / R[i]; 70 71 Total = 1. 0 F / Hold; 72 73 return Total; 74 } 75 76 ~Parallel() {} 77 }; 78 79 void main() 80 { 81 Resistor* ptr; 82 int choice = 0 ; 83 84 int Num = 0 ; 85 float* Temp; 86 87 char option; 88 89 while( 1 ) 90 { 91 cout<<"Which circuit you want to calculate ( 1 : Series, 2 : Parallel) \n"; 92 cin>>choice; 93 94 if(choice != 1 && choice!= 2 ) 95 { 96 cout<<"Not a Valid choice \n"; 97 cin.clear(); 98 cin.ignore(INT_MAX, '\n'); 99 continue; 100 } 101 102 cout<<"How many resistances are there in your circuit: \n"; 103 cin>>Num; 104 105 Temp = new float[Num]; 106 107 cout<<"Enter the resitance of each resistor: \n"; 108 for(int i = 0 ; i < Num; i++) 109 { 110 cout<<i+ 1 <<" : "; 111 cin>>Temp[i]; 112 } 113 114 switch(choice) 115 { 116 case 1 : 117 ptr = new Series(Num, Temp); 118 cout<<"Total resistance is : "<<ptr‐>total_resistance()<<endl; 119 delete ptr; 120 break; 121 122 case 2 : 123 ptr = new Parallel(Num, Temp); 124 cout<<"Total resistance is : "<<ptr‐>total_resistance()<<endl; 125 delete ptr; 126 break; 127 } 128 129 delete[] Temp; 130 131 132 cout<<"Another (y/n) : ";