0
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
double V,I,pf,Ib;
unsigned short int choice;
int In = 0;

cout<<"Please choose power supply type\n";
cin>>choice;

switch(choice)
{
case 1:cout<<"You have chosen a single phase power supply\n";
	break;
case 2:cout<<"You have chosen a three phase power supply\n";
		   break;
default:cout<<"Invalid Choice Try Again\n";
	break;

}
cout<<"Please enter the value for I\n";
cin>>I;
cout<<"Please enter the value for V\n";
cin>>V;
cout<<"Please enter the value for pf\n";
cin>>pf;

if(choice<2)
{
	cout << "Ib in single phase is " << setprecision(4)
     << (V*I)/V/pf
     << setprecision(4) << endl;
}
else
{
	cout << "Ib in three phase is" << setprecision(4)
     << (V*I)/(1.732*V*pf)
     << setprecision(4) << endl;
}

while(Ib>In)
{
	In+=1;
	
}

return 0;
}

Hi im new to C++ and was wondering if i could get some help how do i take the value accquired in the if else and assign it to the variable Ib?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by tkud
1
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
double V,I,pf,Ib;
unsigned short int choice;
int In = 0;

cout<<"Please choose power supply type\n";
cin>>choice;

switch(choice)
{
case 1:cout<<"You have chosen a single phase power supply\n";
	break;
case 2:cout<<"You have chosen a three phase power supply\n";
		   break;
default:cout<<"Invalid Choice Try Again\n";
	break;

}
cout<<"Please enter the value for I\n";
cin>>I;
cout<<"Please enter the value for V\n";
cin>>V;
cout<<"Please enter the value for pf\n";
cin>>pf;

if(choice<2)
{
     Ib=(V*I)/V/pf;//First compute Ib here
	cout << "Ib in single phase is " << setprecision(4)
     << Ib//Then output the value
     << setprecision(4) << endl;
}
else
{
    Ib=(V*I)/(1.732*V*pf);//Compute first
	cout << "Ib in three phase is" << setprecision(4)
     << Ib<<endl//then output
     << setprecision(4) << endl;
}

while(Ib>In)
{
	In+=1;
	
}

return 0;
}

Edited by tkud: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.