Need help outputing months and days.

This program works fine but I am having trouble outputting the months and day and I can't seem to find a way to display them on output as I continually getting 1,2,3,4 and so on under "week of" column . I need to have output that shows something like this below. Please help me fix this issue. Will appreciate it a lot.

Week of Gallons Miles MPG
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
February 4 9.8 196 42
February 11 9.5 182 42
February 18 5.6 101 42
February 25 7.5 133 42

My Code:

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
#include <iostream>
#include <cstring>
using namespace std;
#define Max_weeks 100
int getNumberofweeks();
int getGallonsamount(int,float*);
int getMilesamount(int,float*);
void CalcAverage(float[],int,float[]);
float Gallons[Max_weeks];
float Miles[Max_weeks];
float MPG[Max_weeks];
void display(int);
void main()
{
  int Numweeks;
  Numweeks = getNumberofweeks();
  getGallonsamount(Numweeks, Gallons);
  getMilesamount(Numweeks, Miles);
  CalcAverage(Gallons,Numweeks,Miles);
  display(Numweeks);
  cin.ignore(2);
}
int getNumberofweeks()	 // functions that gets total number weeks
{
	int weekInput;
   cout << "Enter the number of weeks: ";
   cin>>weekInput;
   cout<<endl;
   return weekInput;
}
int getGallonsamount (int count , float *MPG)	// function that gets amount of gallons
 {
    cout<<endl;

    for (int Gallons = 0; Gallons <count; ++Gallons)
	{
	  cout << "enter amount of gallons for "<< Gallons+1 <<": ";
	  cin >> *MPG;
	  MPG++;
	}
    cout<<endl;
    return 0;
 }
int getMilesamount (int count , float *MPG)   // function that get average miles
 {
    cout<<endl;
    for (int Miles = 0; Miles <count; ++Miles)
	{
	  cout << "enter amount of miles for "<< Miles+1 <<": ";
	  cin >> *MPG;
	  MPG++;
	}
    cout<<endl;
    return 0;
 }
void CalcAverage(float Gallons[],int count, float Miles[])  // function that calculates MPG
  {
	 
	for (int week = 0; week < count; week++)
	   {
	       MPG[week] = (Miles[week]) / (Gallons[week]);
	  }
  }
void display(int count) // function that display the mark details along with total average
{
	 
      float TotalGallons=0.0;
      float TotalMiles=0.0,TotalMPG=0.0;  // variables for finding total
      float AvgMPG;                      // variables for finding average
      cout<<"\n\nWeek of"<<"\t\t"<<"Gallons"<<"\t"<<"Miles"<<"\t\t"<<"MPG"<<endl;
	  string week[4] = {"February 4", "February 11","February 18","February 25"};
	  for(int week=0; week<count ; week++) 
		
	{
	    cout<<week+1<<"\t\t"<<Gallons[week]<<"\t"<<Miles[week]<<"\t\t"<<MPG[week]<<endl;
		TotalGallons = TotalGallons + Gallons[week];
	    TotalMiles = TotalMiles + Miles[week];
	    TotalMPG = TotalMPG + MPG[week];
	  }
	  {
      AvgMPG = TotalMPG / count;
      cout<<"\n Total Gallons :"<<TotalGallons;
      cout<<"\n Total Miles   :"<<TotalMiles;
      cout<<"\n Average MPG   :"<<AvgMPG;
	}
}
Topic archived. No new replies allowed.