question archive Ok, so i am basically stuck on a programs on linux who doesn't respond the way in the way that i will like it to respond
Subject:Computer SciencePrice:9.82 Bought3
Ok, so i am basically stuck on a programs on linux who doesn't respond the way in the way that i will like it to respond. First, here is the question:
Basically, i am stuck at the part 4 where it ask to be case sensitive and give a specific output. The way by which i am doing obligatory which means i need use (case and esac); however the output of my programs doesn't give the expected result.
Result output:
[]$ ./_day.sh
Bonjour, can i ask you a question?yes
What is your favorite day of the week?
, who likes .
[]$ ./_day.sh
Bonjour, can i ask you a question?yes
What is your favorite day of the week?
Wednesday
, who likes .
[]$ vi _day.sh
[]$ ./_day.sh
Bonjour, can i ask you a question?
Heuh escuse me,I SAID:CAN I ASK YOU A QUESTION?! (you have to respond yes or no )TUesday
Heuh escuse me,I SAID:CAN I ASK YOU A QUESTION?! (you have to respond yes or no )yes
What is your favorite day of the week?
TUesday
, who likes .
Please, i know it's tempting to simply use another way to finish this programs, but i need to know how to solve it using the case-statement method.
The problem in your code is that you are using "or" which is the linux equivalent of the logical OR operator in C. Linux' OR operator evaluates both arguments and then returns the value to be 0. You should be using something like eq or neq instead of or.
Since we already know what the answer will be (because you have set up your conditions with if commands, and you did not check for an empty string) all that I need you to do is print something out when any input matches those conditions (yes, yEs, YES, YEs, etc).
Try making these changes:
Your code should work for any combination of upper and lowercase letters that the user enters for any of the first input questions.
Step-by-step explanation
For example, yes, Yes, YeS, yES, YES, YEs, etc should all work for any input.
Ok. How to do the changes:
(case and esac are the same thing here)