For this C++ hw fill in the code where its required Create a function called time2Greeting. It takes a time (in military time) and returns a string with the right greeting. Good Morning 4AM to before noon. Good Afternoon Noon to before 5PM Good Evening from 5PM to 11PM What are you doing up at this hour? between 11 and 4AM For illegal values, say: That is not a valid time. Example: What is your name? John What time is it? 1315 Good afternoon, John. code: #include <iostream>using namespace std; string time2greeting() // add the parameter here{// add logic here to return// Good Morning from 400 to before noon.// Good Afternoon from Noon to before 5PM// Good Evening from 5PM to 11PM// What are you doing up at this hour? between 11PM and 4AM//For illegal values, say:// That is not a valid time. } int main(){string name;int time;cout << "What is your name? ";cin >> name;cout << "What time is it? (0-2400)";cin >> time;// call and print time2greeting}
For this C++ hw fill in the code where its required
Create a function called time2Greeting.
It takes a time (in military time) and returns a string with the right greeting.
Good Morning 4AM to before noon.
Good Afternoon Noon to before 5PM
Good Evening from 5PM to 11PM
What are you doing up at this hour? between 11 and 4AM
For illegal values, say:
That is not a valid time.
Example:
What is your name? John
What time is it? 1315
Good afternoon, John.
code:
#include <iostream>
using namespace std;
string time2greeting() // add the parameter here
{
// add logic here to return
// Good Morning from 400 to before noon.
// Good Afternoon from Noon to before 5PM
// Good Evening from 5PM to 11PM
// What are you doing up at this hour? between 11PM and 4AM
//For illegal values, say:
// That is not a valid time.
}
int main()
{
string name;
int time;
cout << "What is your name? ";
cin >> name;
cout << "What time is it? (0-2400)";
cin >> time;
// call and print time2greeting
}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images