Question

I am trying to print a table that looks like this:

                       Number of Queues

 Oc           2               3             4              5
50,000   average-max    average-max    average-max   average-max
100,000  average-max    average-max    average-max   average-max
150,000  average-max    average-max    average-max   average-max

etc etc

where average is the getAverage() and max is the getMax().

amount contains the stepped Oc value.

The code I have been trying to use to do this is below:

cout << setw(5) << "Oc" << setw(10) << "2" << setw(5) << "3" << setw(5) << "4" << setw(5) << "5" << endl << endl;

while (amount < 400000)
{
        amount += 50000;

        for (int i = 2; i <= 5; i++)    //2 and 5 for the number of queues
        {   
            Simulator simulator(i, amount);

            simulator.start();

            cout << setw(5) << amount << setw(10) << simulator.getAverage() << "-" << simulator.getMax();

        } //end for loop

} //end while loop

I need some help fixing this to display the table properly, it's all over the place at the moment.

Was it helpful?

Solution

while (amount < 400000)
{
        amount += 50000;

        for (int i = 2; i <= 5; i++)    //2 and 5 for the number of queues
        {   
            Simulator simulator(i, amount);

            simulator.start();

            cout << setw(5) << amount << setw(10) << simulator.getAverage() << "-" << simulator.getMax() << "\t";

        } //end for loop

} //end while loop

You can use "\t"

OTHER TIPS

cout << setw(6) << "Oc" << setw(10) << "2" << setw(10) << "3" << setw(10) << "4" << setw(10) << "5" << endl << endl;

while (amount < 400000)
{
        amount += 50000;
        cout << setw(5) << amount;
        for (int i = 2; i <= 5; i++)    //2 and 5 for the number of queues
        {   
            Simulator simulator(i, amount);

            simulator.start();

             cout << setw(10) << simulator.getAverage() << "-" << simulator.getMax();

        } //end for loop
        cout << endl;   

} //end while loop

Good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top