Output a transformer object with labels

What will be an ideal response?


```
ostream& operator<< (ostream& os, const Transformer& t)
{
os << endl << "N1: " << t.N1 << " loops, N2: " << t.N2 << " loops"
<< endl << "V1: " << t.V1 << " volts, V2: " << t.vOut()
<< " volts" << endl << "i1: " << t.i1 << " amps, i2: "
<< t.iOut() << " amps" << endl;
return os;
}

int main()
{
Transformer trans;
double v, i;

cout << endl << "Enter a transformer's input coils, output coils,"
<< endl << "input voltage and input current => ";
cin >> trans;
cout << endl << "Transformer entered was:" << trans;

cout << endl << "Enter desired output voltage => ";
cin >> v;
cout << endl << "Possible configurations:" << endl;
Transformer trans1 = trans; // make copy for modifications
trans1.setN1forV2(v);
cout << trans1;
Transformer trans2 = trans;
trans2.setN2forV2(v);
cout << trans2;
Transformer trans3 = trans;
trans3.setV1forV2(v);
cout << trans3;

cout << endl << "Enter desired output current => ";
cin >> i;
cout << endl << "Possible configurations:" << endl;
Transformer trans4 = trans;
trans4.setI1forI2(i);
cout << trans4;
Transformer trans5 = trans;
trans5.setN1forI2(i);
cout << trans5;
Transformer trans6 = trans;
trans6.setN2forI2(i);
cout << trans6;

cout << endl;

return 0;
}

```

Computer Science & Information Technology

You might also like to view...

Overloaded functions and operators demonstrate

A. Execution-time polymorphism. B. Run-time polymorphism. C. Compile-time polymorphism. D. None of the Above.

Computer Science & Information Technology

The icon of a megaphone appears on a slide when a(n) ________ is inserted

Fill in the blank(s) with correct word

Computer Science & Information Technology

The smallest individual unit of a program written in any language is called a(n) ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

What is wrong with this Java statement?

int num = new int(5);

Computer Science & Information Technology