Help please

I need this program to work so that I can enter decimals instead of whole numbers. I don't know what I'm doing wrong. Can someone please help?

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
#include <iostream>
using namespace std;

int main()
{
	const int SIZE = 12; // Constant for array size
	int values[SIZE]; // Array to hold values
	int index = 0;

	// Get the values.
	for (; index < SIZE; index++)
	{
		cout << "Enter the amount of rainfall for month "
			<< index + 1 << ": ";
		cin >> values[index];
	}

	double total = 0;

	// Step through that array, adding each element to
	// the accumulator.
	for (int index = 0; index < SIZE; index++)
	{
		total += values[index];
	}

	//Display the total.
	cout << "The total amount of rainfall is " << total << endl;

	double average;

	// Calculate the average.
	average = total / SIZE;

	// Display the average.
	cout << "The average rainfall is " << average << endl;

	double highest = values[0];

	// Step trough the rest of the array, beginning at
	// element 1. When a value greater than highest is found,
	// assign that value to highest.
	for (int index = 0; index < SIZE; index++)
	{
		if (values[index] > highest)
		{
			highest = values[index];
		}
	}

	// Display the highest value.
	cout << "The highest amount of rainfall is " << highest << endl;

	double lowest = values[0];

	// Step through the rest of the array, beginning at
	// element 1. When a value less than lowest is found,
	// assign that value to lowest.
	for (int index = 0; index < SIZE; index++)
	{
		if (values[index] < lowest)
		{
			lowest = values[index];
		}
	}

	// Display the lowest value.
	cout << "The lowest amount of rainfall is " << lowest << endl;

	return 0;
}
int values[SIZE]; // Array to hold values

should become

double values[SIZE];
Just change this:
 
int values[SIZE]; // Array to hold values 


To this:
 
double values[SIZE];
Wow. Now I feel dumb. Thank you!
Topic archived. No new replies allowed.