1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
double calc_volts(double[], double[], double[]);
int main()
{
int j=0;
double current[10] = {10.62,14.89,13.21,16.55,19.62,9.47,6.58,18.32,12.15,3.98};
double volts[10];
double resistance[10] = {4,8.5,6,7.35,9,15.3,3,5.4,2.9,4.8};
volts[j] = calc_volts(current, volts, resistance);
cout<<"This program will output the voltage from a given current and resistance"<<endl<<endl;
for (j = 0; j<10; j++)
{
cout<<setw(6)<<fixed<<setprecision(3)<<"Current"<<j<<": "<<current[j]<<endl;
cout<<setw(6)<<fixed<<setprecision(3)<<"Resistance"<<j<<": "<<resistance[j]<<endl;
cout<<setw(6)<<fixed<<setprecision(3)<<"Volts"<<j<<": "<<volts[j]<<endl;
}
system("pause");
return 0;
}
double calc_volts(double current[],double volts[], double resistance[])
{int j;
for (j = 0; j<10; j++)
{volts[j] = (current[j])*(resistance[j]);
}
return volts[j];
}
double printvolts (double outputvoltage[])
{for(int v=0;v<10;v++)
cout<<setw(6)<<fixed<<setprecision(3)<<outputvoltage[v]<<endl;
return 0;
}
|