Thursday, 11 December 2014

Write a Shell Script to present a user with a multiple choice question, what is the capital of India 1) Delhi 2) Bangalore 3) Madras 4) Mumbai 5) None of the above Prompt the user for the answer and the system should instantly inform the user about correctness of the answer.

Write a Shell Script to present a user with a multiple choice question, what is the capital of India
1) Delhi
2) Bangalore
3) Madras
4) Mumbai
5) None of the above
Prompt the user for the answer and the system should instantly inform the user about correctness of the answer.

Solution:
echo What is the Capital of India
echo 1 Delhi
echo 2 Banglore
echo 3 Madras
echo 4 Mumbai
echo 5 None of the above
echo Choose the correct Answer
read choice
case $choice in
1) echo Your Answer is Correct ;;
2) echo Wrong Answer ;;
3) echo Wrong Answer;;
4) echo Wrong Answer ;;
5) echo Wrong Answer;;
*) echo Invalid choice;;

esac

Execution:

No comments:

Post a Comment