can someone give me a hand my exam will be after two days
Your program should contain at least the following functions with suitable parameters:
LoadInfo(string city,int yesTemps,int todayTemps): reads the city name and the temperatures
for the yesterday and today for each city from an input file named "temps.dat", and stores city names
in 1D array of strings and temperatures in two 1D arrays. The function should count and return the
number of cities in the input file.
PredictCitiesTemps(int yesTemps,int todayTemps,int tomorrowTemps,int n): receives the
temperatures for yesterday and today for all cities using two 1D arrays and uses the random number
generator to predict tomorrow’s temperature for each city. It computes the tomorrow’s temperature
for a given city as the average temperature for the previous two days (yesterday and today) plus a
random number between –3 and +3. For example the average temperature for Muscat city is
(30+32)/2=31. Therefore, tomorrow’s temperature in Muscat can be between 31-3=28 and 31+3= 34.
Display(string city,int yesTemps,int todayTemps,int tomorrowTemps,int n): displays the
city name and the temperatures for the 3 days for each city in the screen using a tabular format as
shown in figure 2.
getHottestCity(string city,int temps,int n): accepts city names and the temperatures for a given
day (either for yesterday, today, or tomorrow) as two arrays and returns the name of the city with the
PrintToExcelFile(string city,int tomorrowTemps,int n): writes the city name and tomorrow’s
temperature for each city into an Excel file named "predTemp.xls " as shown in figure 3. To create
an Excel document, you need to name your document with ".xls" extension and separate columns
using the Tab key ("\t" in C++).
On this line you are assigning the return value of the function to Num_elements. However, the function returns 0. If you want the actual number of elements of the city array you'll have to return num_elements itself from the function. However, the way you have it written it's only return the size of an element. I forget exactly how you get the number of elements from an array but basically you have to divide the size of the array by the size of a single element, something like return (sizeof(city)/sizeof(city)). If I remember correctly that is. :)
Also, this way you are returning the value itself and don't need the num_elements variable in the function. Not a huge different, but it's a little more elegant of a solution.