Apr 7, 2013 at 7:42am UTC
Is it possible to prompt information from user then display the result in a one dimensional array form? If yes can anyone tell me how should i link them together?
Apr 7, 2013 at 7:58am UTC
What input you want to take? What do you mean by "one dimensional array form"?
Show an example please.
Apr 7, 2013 at 8:29am UTC
@MiiNiPaa the salary received by an employee.
sample of one dimensional array:
int main ()
{
int grossSales [10];
int t;
for (t=0; t<10; t++) grossSales[t] = t;
for (t=0; t<10; t++)
cout << "This is gross sales[" << t << "]: " << grossSales[t] << "\n";
}
Apr 7, 2013 at 8:42am UTC
@MiiNiPaa this is the latest coding i have done just now but the answers are still weird...
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main ()
{
int i;
double salary = 0;
double gross[10];
for (i=0; i<10; i++)
{
cout << "Please enter the gross sales that you have made for the week: " << endl;
cin >> gross[0];
salary = 200 + (0.09 * gross[i]) ;
cout << setprecision(3) << "\n\nYour commission for the week: " << salary << endl;
}
}
Apr 7, 2013 at 8:48am UTC
cin >> gross[0];
err... shouldn't it be cin >> gross[i];
?
Apr 7, 2013 at 8:48am UTC
@MiiNiiPaa hmm and any idea how can i categorise all my results into the following categories?
$200 - $299
$300 - $399
$400 - $499
$500 - $599
$600 - $699
$700 - $799
$800 - $899
$900 - $999
which statement should i use or do you have any examples? sorry for bothering you ):
Apr 7, 2013 at 8:49am UTC
@MiiNiiPaa "cin >> gross[0]; err... shouldn't it be cin >> gross[i];" wait let me try that out.