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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am having some issues with my code when I run it.

The instruction for the hw was as follows:

For this C++ hw

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.

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);

}

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
Transcribed Image Text: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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education