#include using namespace std; const float RESIST = 10.0; // resistance in ohms // get the low voltage value from the user float getlow() { float lowvoltage; cout << "Enter the lower voltage in volts "; cin >> lowvoltage; return lowvoltage; } // getlow // get the high voltage value from the user float gethigh() { float highvoltage; cout << "Enter the higher voltage in volts "; cin >> highvoltage; return highvoltage; } // gethigh // check the ranges of the voltage values bool checkval(float highvoltage, float lowvoltage) { if(lowvoltage < 0) { cout << "low voltage must be greater than 0" << endl; return(false); } if(highvoltage < 0) { cout << "high voltage must be greater than 0" << endl; return (false); } if (highvoltage < lowvoltage) { cout << "high voltage must be greater than low voltage" << endl; return (false); } return true; // everything is fine } // checkval int main(int argc, char * argv[]) { float lowvoltage, highvoltage; float power, current; // get user input lowvoltage = getlow(); highvoltage = gethigh(); // check validity of input data if(checkval(highvoltage,lowvoltage) == false) { exit(1); } // calculate the table cout << "Voltage" << "\t" << "Power" << "\t" << "Current" << endl; for(float v = lowvoltage; v <= highvoltage; v++) { power = (v * v) / RESIST; current = v/RESIST; cout << v << "\t" << power << "\t" << current << endl; } return 0; } // main