How to make something constant in an assignment

I finished this assignment:


#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

int main ()
{

ifstream in;

/*In your program, open the file temp.txt and read the numbers into an array called ‘temp’.*/
in.open("temp.txt");

/*Create a second array with the names of the months with Jan=index 0 and so on.
They should match up index-wise with the temperatures. This will be hardcoded in your program*/

string months[]= { "Jan", "Feb", "March",
"April", "May", "June",
"July", "Aug", "Sept",
"Oct", "Nov", "Dec" };
int i;
float far[12];
float cel[12];

cout << endl;
cout << "Calender" << "\t" << "Average Temperature" << "\t" << "Average Temperature" << endl;
cout << "Month" << "\t\t" << "Farenheit" << "\t\t" << "Celsius" << endl;
cout << "-----------------------------------------------------------" << endl;

for (int i=0; i< 12; i++)
{
in >> far[i];

//Formula and conversion
cel[i] = 5*(far[i]-32)/9;

cout << fixed << showpoint << setprecision(1);
cout << months[i] << "\t\t" << far[i] << "\t\t\t" << cel[i]<< "\t\t -"<<endl;
cout << "-----------------------------------------------------------" << endl;


}

in.close();


return 0;
}



And these are the instructions:

1. create 2 arrays
2. read one in from a file called temp.txt
3. hardcode one with months of the year – this is an array of string types
4. read through the array of temperatures and convert temps to celsius.
5. print out columns of month, farenheit, celsius temps

Jan Feb March April May June July Aug Sept Oct Nov Dec
25.7 31.2 42 58.5 61.2 82.7 85.6 81.2 70.8 63.5 55.2 35.4

The numbers above represent average temperature in farenheit for each month of the year in some locality. Copy the float values into a text file, don’t worry about the headings. You’ll have a text file called temp.txt with only this in it:
25.7 31.2 42 58.5 61.2 82.7 85.6 81.2 70.8 63.5 55.2 35.4

In your program, open the file temp.txt and read the numbers into an array called ‘temp’.

Create a second array with the names of the months with Jan=index 0 and so on. They should match up index-wise with the temperatures. This will be hardcoded in your program. Ex: string months[ ] = {“Jan”, “Feb”, “Mar”…}. Don’t make this a two-dimensional array of chars! The SIZE of each array must be a const.

Read through the temperature array and convert the temperatures from the first array to celsius using the following formula:

Celsius = 5(Farenheit-32)/9

You can read temps in from file in one loop, then loop through the array a second time to get celsius.

Print the following information out the screen:

Month (tab) avg. temp farenheit (tab) avg temp celsius
Jan temp temp
Feb temp temp
Mar …

You’ll probably have to put additional tabs in the data part to make it line up. See if you can get it to line up nicely. This program demonstrates use of parallel arrays.







And now I'm being asked to make 12 a constant .. I thought I did that with the two arrays? Please help!
Topic archived. No new replies allowed.