Question in the description. I beg you all please send me the solution for this please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Question in the description. I beg you all please send me the solution for this please

Write a program that simulates a traffic light. The program should consist of the following: 1. A user defined function trafficLight( ) that accepts input from the user, displays an error message if the user enters anything other than RED,YELLOW, and GREEN. Function light() is called and following is displayed depending upon return value from light(). a) “STOP, your life is precious” if the value returned by light() is 0. b) “Please WAIT, till the light is Green “ if the value returned by light() is 1 c) “GO! Thank you for being patient” if the value returned by light() is 2. 2. A user defined function light() that accepts a string as input and returns 0 when the input is RED,1 when the input is YELLOW and 2 when the input is GREEN. The input should be passed as an argument. 3. Display “ SPEED THRILLS BUT KILLS” after the function trafficLight( ) is executed.

15th May 2020, 7:05 AM
Raj Panda
Raj Panda - avatar
15 Answers
+ 1
#include <iostream> Using namespace std; Int main() { Int yellow; Int green; Int red; //You enter the color here Cout<<"please input a color"<<endl; Cin>>x; If(x==red){ Cout<<"stop"<<blah blah blah"<<endl; } If(x==yellow){ Cout<<"wait"<<blah blah blah<<endl; } If(x==green){ Cout<<"go"<<endl; } }
17th May 2020, 12:41 AM
$#inobi
$#inobi - avatar
0
Sir actually i am not able to understand how to go with it thats I wanted help from ur side. So sir please could you hel me
15th May 2020, 7:27 AM
Raj Panda
Raj Panda - avatar
0
A small guidance could also help
15th May 2020, 7:28 AM
Raj Panda
Raj Panda - avatar
0
But sir i am not able to proceed with it. I am very new to python so i am still learning how to code. Sir i really dont know how to to it
15th May 2020, 7:30 AM
Raj Panda
Raj Panda - avatar
0
Please could you help
15th May 2020, 7:30 AM
Raj Panda
Raj Panda - avatar
0
Thankyou sir. Sir i am not able to understand how do we use light() user defined fucntion here and write the program
15th May 2020, 7:31 AM
Raj Panda
Raj Panda - avatar
0
Thanks a lot for helping sir
15th May 2020, 7:32 AM
Raj Panda
Raj Panda - avatar
0
Sure sir i will wait
15th May 2020, 7:34 AM
Raj Panda
Raj Panda - avatar
0
Sir are you there???
15th May 2020, 7:41 AM
Raj Panda
Raj Panda - avatar
0
Even if you could provide me the information (theory)related to this question will help a lot
15th May 2020, 7:41 AM
Raj Panda
Raj Panda - avatar
0
Thankyou so much sir. You helped me a lot. May God bless you.
15th May 2020, 7:44 AM
Raj Panda
Raj Panda - avatar
0
Sir you have helped me a lot. Once again thanks a lot.
15th May 2020, 7:44 AM
Raj Panda
Raj Panda - avatar
0
Sure sir will definitely seek for help from you i have marked ur answers as the best
15th May 2020, 7:47 AM
Raj Panda
Raj Panda - avatar
0
Hope it works
17th May 2020, 12:42 AM
$#inobi
$#inobi - avatar
0
Thankyou so much $#inobi for helping me. May God blees you. Sir i am following you now so that i can ask my further doubts in future.
17th May 2020, 1:31 AM
Raj Panda
Raj Panda - avatar