Use beginner/intermediate C+ needed)) skills and such as (out cin case swith iff
ID: 3755304 • Letter: U
Question
Use beginner/intermediate C+ needed)) skills and such as (out cin case swith iffelse statements.etc if If there are 91 days in any of the four seasons of a year for simplicity and the first season of a year is winter. Write a program to read a number from an input file. Representing the number of days from the beginning of a year. The program should then find and print the number and its corresponding season to an output file in tabular form like the following table. Note the alignment within each column. Input 95 210 312 Output Winter Spring Summer FallExplanation / Answer
//C++ program
#include<iostream>
#include<fstream>
using namespace std;
int main(){
ifstream in;
ofstream out;
in.open("input.txt");
out.open("output.txt");
int day;
while(!in.eof()){
in>>day;
if(day>=1 && day<= 91)out<<day<<" Winter ";
else if(day>=92 && day<= 182)out<<day<<" Spring ";
else if(day>=183 && day<= 273)out<<day<<" Summer ";
else if(day>=274 && day<= 364)out<<day<<" Fall ";
else out<<" ";
}
in.close();
out.close();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.