I need this program to be able to display 4th quarter inventory in this format:
October 200
November 250
December 350
I need it to display in an array. This what i have so far:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
const int N_MONTHS = 12;
int stock;
int values[N_MONTHS];
int count;
double total = 0;
double avg;
int largest;
int smallest;
string p_months[N_MONTHS] = { "January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December" };
for ( int month = 1; month <= N_MONTHS; month++ ){
cout << "Enter the number of items in stock for the month of " << p_months[month-1] << ": ";
cin >> stock;
if ( stock < 0 ){
cout << "The number you have entered is invalid." << endl;
cout << "Please reenter: ";
cin >> stock;
}
values[month-1]=stock;
total += stock;
total += stock;
}
cout << "The amount of items in stock is: " << total << endl;
avg = total / (double)N_MONTHS;
for ( int month = 1; month <= N_MONTHS; month++ ){
largest = values[0];
for ( count = 1; count < N_MONTHS; count++ ){
if ( values[count] > largest ){
largest = values[count];
}
}
smallest = values[0];
for ( count = 1; count < N_MONTHS; count++ ){
if ( values[count] < smallest ){
smallest = values[count];
}
}
}
cout << "Items in stock for the fourth quarter are as follows " << endl;
cout << N_MONTHS+9 << endl;
system("pause");
return(0);
}
I have gotten it as far as I can think of. My brain is fried and I am frustrated.