| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ok usually I can take a break come back and bam theres the problem... Unfortunately not this time.
I'm getting an error message before the 'else'. Any help would be much appriciated! Code:
/* This program will read in up to 24 Temperatures as integers. It will also Calculate the highest
and lowest temperatures and then give and average of the temperatures .*/
#include <iostream>
#include <iomanip>
using namespace std;
int aTemp, counter, numRead, highest, lowest;
double avg;
int main()
{
cout << "Enter the number of temperature to be read: ";
cin >> numRead;
if (numRead > 24 || numRead < 0);
{
cout << "Error: The number of temperatures entered must be under 24.";
else
cout << "Enter the list of temperatures: ";
}
cin >> aTemp;// Calculate first temperature checks the records to see if its the highest and lowest
for(counter = 1; counter <= numRead; counter++)
{
cin >> aTemp;
if(aTemp > highest)// Update the highest so far, if necessary
{
highest = aTemp;
}
if(aTemp < lowest)// Update the lowest so far, if necessary
{
lowest = aTemp;
}
}
avg = ((highest + lowest)/ counter);
cout << "The highest temperature is: " << highest << endl;
cout << "The average temperature is: " << avg << endl;
cout << "The lowest temperature is: " << lowest << endl;
return 0;
}
|
|
#2
|
|||
|
|||
|
thats very sad that out of the 25 people who viewed no one caught that my mistake was that the if statemtent had a semicolon. I'm making sure not to recommend this site to anyone.
|
|
#3
|
||||
|
||||
|
Remind me again why its sad that people are trying to help you?
|
|
#4
|
|||
|
|||
|
I'm sure with your attitude you probably don't have anyone to recommend this site to in the first place. Sometimes you're not going to get a response immediately and if you don't just look back at your work to see if you can solve it yourself. Keep checking back to see if people have responded. You don't have to get mad at this site because you found the problem before anybody else did.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Stuck |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|