Debugglng Informatlon for Loco overTime O DESCRIPTION Value too high DEBUG INFO Your instructor has chosen to give you the following information to help you debug your code and improve your submission. COMPILER STACK TRACE None PROGRAM EXECUTION STACK TRACE None INPUT OF THE TEST CASE 1 Loco 2 5900 YOUR CODE'S OUTPUT 1 what is your name? What time is it? (0-2400)What are you doing up, Loco 2 THE CORRECT OUTPUT OF THE TEST CASE 1 What is your name? What time is it? (0-2400)That is an illegal time, Loco 2 "UNIX DIFF OF CORRECT OUTPUT AND YOUR OUTPUT 1c1 < what is your name? What time is it? (0-2400)What are you doing up, Loco > what is your name? What time is it? (0-2400)That is an illegal time, Loco PRETTY DIFF This diff is colored to make it clear what parts of the output are wrong. Green indicates things in the correct output that you are mlssing, red indicates things in your output that shouldn't be there. The - character refers to newlines, so the green - character refers a newline you are missing in your output and the red refers to a newiline you need to remove from your output. 1 what is your name? What time is it? (0-2400)WThat areis youan doinllegal uptime, Locod Debugglng Informatlon for Loca crazytlme O DEBUG INFO Your instructor has chosen to give you the following information to help you debug your code and improve your submission. COMPILER STACK TRACE None PROGRAM EXECUTION STACK TRACE None INPUT OF THE TEST CASE 1 Loca 2 -1200 YOUR CODE'S OUTPUT 1 what is your name? What time is it? (0-2400)What are you doing up, Loca 2 THE CORRECT OUTPUT OF THE TEST CASE 1 what is your name? What time is it? (0-2400)That is an illegal time, Loca 2 "UNIX DIFF OF CORRECT OUTPUT AND YOUR OUTPUT 1c1 < what is your name? What time is it? (0-2400)What are you doing up, Loca > what is your name? What time is it? (0-2400)That is an illegal time, Loca PRETTY DIFF This diff is colored to make it clear what parts of the output are wrong. Green indicates things in the correct output that you are mlssing, red indicates things in your output that shouldn't be there. The a character refers to newlines, so the green character refers a newline you are missing in your output and the red refers to a newiline you need to remove from your output. 1 what is your name? What time is it? (0-2400)WThat areis youan doinllegal uptime, Locad TIT
having some issues with my c++ code.
Below I have attached the a screenshot of the errors I receive when I run it. For both of them it should say that is an illegal time instead of what are you doing up.
My code:
#include <iostream>
#include <string>
using namespace std;
//method to compute the greeting at a certain time
string time2greeting(int time)
{
//create a string to hold greatings
string greeting;
//if time is between 11PM and 4AM
if (time > 2259 || time < 400)
//set the greating " What are you doing up,"
greeting = "What are you doing up, ";
//if time is between from 5PM to 11PM
else if (time > 1659)
//set the greeting "good evening"
greeting = "Good Evening, ";
//if time is from Noon to before 5PM
else if (time > 1159)
//set the greeting "good Afternoon"
greeting = "Good Afternoon, ";
//if time is greater tha 359
else if (time > 359)
//set the greeting "good Morning"
greeting = "Good Morning, ";
//For illegal values, say:
else
//set the greeting
greeting = "That is an illegal time, ";
//return the greeting
return greeting;
}
//define main method
int main()
{
//declare the variables
string name, greeting;
int time;
//prompt the user to enter the name
cout << "What is your name? ";
//scan for the value
cin >> name;
//prompt the user to enter the time
cout << "What time is it? (0-2400)";
//scan for the time
cin >> time;
// call and print time2greeting
greeting = time2greeting(time);
//print the output
cout << greeting << " " << name << endl;
//return
return(0);
}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 10 images