I want to output every data that I entered in the for loop in a tabular form. Unfortunately, the output only displays the last set of data that I entered. Any solution to solve this?
#include <iostream>
using namespace std;
int main()
{
double voltage, rpm, current, range;
int total; // total set enter by user
cout << "Please enter how many sets of data you want to calculate:";
cin >> total;
cout << "\n";
for(int i=1; i<=total; i++)
{
cout << "Enter he voltage " << i << ":";
cin >> voltage;
cout << "Enter the current " << i << ":";
cin >> current;
cout << "Enter the rpm " << i << ":";
cin >> rpm;
cout << endl;
double range = (voltage*1.2) + (current*0.5) + (rpm* 0.2);
}
cout << "Voltage\t\tCurrent\t\tRPM\t\tRange\n";
for(int i=1; i<=total; i++)
{
cout << voltage << "\t\t" << current << "\t\t" << rpm
<< "\t\t" << range << endl;
}
return 0;
}