Question

blizzard is a massive snowstorm. Definitions vary, but for our purposes, we will assume that a...

blizzard is a massive snowstorm. Definitions vary, but for our purposes, we will
assume that a blizzard is characterized by both winds of 30 mph or higher and
blowing snow that leads to visibility of 0.5 miles or less, sustained for at least
4 hours. Data from a storm one day has been stored in a file stormtrack.dat.
There are 24 lines in the file, one for each hour of the day. Each line in the file has
the wind speed and visibility at a location. Create a sample data file. Read this
data from the file and determine whether blizzard conditions were met during
this day or not.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<fstream>
using namespace std;
int main(){
ifstream f;
int flag1=0;
double w_speed,visibility;
f.open("blizzard.dat");
while( f >> w_speed >> visibility){ //>>operator reads the space separated double values from the file blizzard.dat
if(w_speed > 30 && visibility < 0.5) {
flag1=1;
break;
}
}
if(flag1==1){
cout<<"\nThere was a blizzard during the day\n\n";
}
else{
cout<<"\nBlizzard didn't occur during the day\n\n";
}
f.close();
return 0;
}
the file:blizzard.dat

12.6 0.3
25 0.89
23 0.75
20 0.68
18 0.98
19.9 0.96
20.5 0.90
21 0.82
24.9 0.4
26.2 0.45
32.3 0.36
38 0.29
30 0.39
26.11 0.45
21.22 0.56
18 0.66
19.37 0.55
20.3 0.58
19.54 0.54
20 0.51
21.63 0.55
19.3 0.5
19.55 0.54
20 0.54

Add a comment
Know the answer?
Add Answer to:
blizzard is a massive snowstorm. Definitions vary, but for our purposes, we will assume that a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write in JAVA Get Familiar with the Problem Carefully read the program description and look at...

    Write in JAVA Get Familiar with the Problem Carefully read the program description and look at the data file to gain an understanding of what is to be done. Make sure you are clear on what is to be calculated and how. That is, study the file and program description and ponder! Think! The Storm Class Type Now concentrate on the Storm class that we define to hold the summary information for one storm. First, look at the definition of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT