#include <iostream>
using namespace std ;
float calc_Q(float i) ;


void calcElecRest ()
{
	float I,P,V , Q ;
	do 
	{
		cout << "Power (W) = " ;
		cin >> P ;
		cout << "Voltage (kV) = " ;
		cin >> V ;
	
		
		if (P < 0 || V < 0)
		{
			cout << "Invalid input. Please try again !" << endl ;
			cout << endl ;
		}
	}while (P < 0 || V < 0) ;
	
	I=P/(V*1000) ;
	
	Q = calc_Q (I) ;
	
	cout << "Power, P = " << P << " watts " << endl ;
	cout << "Voltage, V = " << V*1000 << " volts " << endl ;
	cout << "Electric current, I = " << I << " amperes " << endl ;
	cout << "Electric charge, Q = " << Q << " coulumbs " << endl ;
}


float calc_Q (float i)
{
	float t ,q ;
	
	cout << "Enter the time of current flow, t in minutes = " ;
	cin >> t ;
	cout << endl   ;
	
	q=i*(t*60) ;
	
	return q ;
	
}

int main ()
{
	cout << "Please enter the power (P) in Watts" << endl << "and the voltage (V) in kilovolts " << endl << endl ;
	
	calcElecRest () ;
	
	return 0 ;
}
