print stars function in 1D array..??

I'm having trouble with my for loop near the end of the program was able to print everything else can anyone give me a boost here..?? Feelin stuck...No errors right now just tryin to finish off the code...!

Sample Output:

*** end of 27610_Arrays04.cpp program ***


City City Points
--------------- 1---5----10---15---20
Belvidere **********
Freeport ********
Byron ************
Stillman Valley ***************
Rockford *********

*** end of 27610_Arrays04.cpp program ***


Input:
TODO #1: complete the coding of the points array
An integer array of 5 numbers: 10, 8, 12, 15, 9

TODO #2: complete the coding of the cities string array
An string of 5 city names intialized to:
"Belvidere", "Freeport", "Byron", "Stillman Valley", "Rockford"

Compile-time arrays with initialization lists.


Processing & Output:
TODO #3: complete the coding of the call to the printStars() function

TODO #4: code the printStars() function

*/


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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141



#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main(void)
{
   /* declarations ------------------------------------------------*/
   
   
   // constants
   const int SIZE = 5;
   

   // function prototype(s)
   // return by value is used
   void printStars(const int [], const string [], const int);

   // local data (other than arrays)

   // TODO #1: complete the coding of the points array
   //   replace ?? with the correct initialization list
   //    each array cell will store the number of stars for the
   //    corresponding city in the cities array below
    
   // STUDENT CODE BEGINS
   
   int points[SIZE] = {10, 8, 12, 15, 9};
   
   // STUDENT CODE ENDS                          ,




    // TODO #2: complete the coding of the cities string array

   // STUDENT CODE BEGINS
    string cities[SIZE] = {"Belvidere", "Freeport", "Byron", "Stillman Valley", "Rockford"};
   
    // STUDENT CODE ENDS                          
                          



   /* statements   ------------------------------------------------*/

    // start the program
    cout << "*** start of 276Arrays_Ex04.cpp program ***" << endl;
    cout << endl;



   // TODO #3: call display function, passing count array & size
   //   replace the three underlines with the correct parameters
   // STUDENT CODE BEGINS


   printStars(points, cities, SIZE);



   // STUDENT CODE ENDS    


   // terminate the program
   cout << endl;
   cout << "*** end of 276Arrays_Ex04.cpp program ***" << endl << endl;
   cin.get();

   return 0;
}   // end main()





/*--------------------------------------------------------------------//
// Function Name: printStars()
// Parameters:    points : const int[],
//                cities : const string[], 
//                SIZE   : const int
// Return:        void
//
// Purpose: to display cities and their points in a graph
//--------------------------------------------------------------------//
// TODO #4: code the display function
// Suggested Algorithm 

declare local variables (if needed)


Print row 1 of column headings (City             City Points)
Print row 2 of column headings (---------------  1---5----10---15---20)

// print one line for each iteration of the for loop
for each city in the cities array
   print the name of a city
   
   // print one star for each iteration of the for loop
   for the value for that city in the points array
      print a star
   end for loop
   move cursor to next line
End outer loop
move cursor to next line

*/

// STUDENT CODE BEGINS

void printStars(const int points [], const string cities [], const int SIZE)
{
   //declare variables
   int city = 0;
   int citypoints = 0;

   //column headings

   cout << "City";
   
   cout << setw(24) << "City Points";
   
   cout << endl;
   cout << setw(15) << "---------------  1---5----10---15---20" << endl;
   
   
   for( //need help finishing this..<===

   

}


// STUDENT CODE ENDS


so ive updated my code further...anything ppl..??

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main(void)
{
   /* declarations ------------------------------------------------*/
   
   
   // constants
   const int SIZE = 5;
   

   // function prototype(s)
   // return by value is used
   void printStars(const int [], const string [], const int);

   // local data (other than arrays)

   // TODO #1: complete the coding of the points array
   //   replace ?? with the correct initialization list
   //    each array cell will store the number of stars for the
   //    corresponding city in the cities array below
    
   // STUDENT CODE BEGINS
   
   int points[SIZE] = {10, 8, 12, 15, 9};
   
   // STUDENT CODE ENDS                          ,




    // TODO #2: complete the coding of the cities string array

   // STUDENT CODE BEGINS
    string cities[SIZE] = {"Belvidere", "Freeport", "Byron", "Stillman Valley", "Rockford"};
   
    // STUDENT CODE ENDS                          
                          



   /* statements   ------------------------------------------------*/

    // start the program
    cout << "*** start of 276Arrays_Ex04.cpp program ***" << endl;
    cout << endl;



   // TODO #3: call display function, passing count array & size
   //   replace the three underlines with the correct parameters
   // STUDENT CODE BEGINS


   printStars(points, cities, SIZE);



   // STUDENT CODE ENDS    


   // terminate the program
   cout << endl;
   cout << "*** end of 276Arrays_Ex04.cpp program ***" << endl << endl;
   cin.get();

   return 0;
}   // end main()





/*--------------------------------------------------------------------//
// Function Name: printStars()
// Parameters:    points : const int[],
//                cities : const string[], 
//                SIZE   : const int
// Return:        void
//
// Purpose: to display cities and their points in a graph
//--------------------------------------------------------------------//
// TODO #4: code the display function
// Suggested Algorithm 

declare local variables (if needed)


Print row 1 of column headings (City             City Points)
Print row 2 of column headings (---------------  1---5----10---15---20)

// print one line for each iteration of the for loop
for each city in the cities array
   print the name of a city
   
   // print one star for each iteration of the for loop
   for the value for that city in the points array
      print a star
   end for loop
   move cursor to next line
End outer loop
move cursor to next line

*/

// STUDENT CODE BEGINS

void printStars(const int points [], const string cities [], const int SIZE)
{
   //declare variables
   int city = 0;
   int citypoints = 0;

   //column headings

   cout << "City";
   
   cout << setw(24) << "City Points";
   
   cout << endl;
   cout << setw(15) << "---------------  1---5----10---15---20" << endl;

   for(int index = 0; index < SIZE; index++)
   {
      if(cities[index] < SIZE)

   

   

}
So I will seriously quickpay someone to finish this code for me...! LBVS..!!!
Topic archived. No new replies allowed.