Question

In: Computer Science

Write a shell script of the following: “A Multiple Choice Question that contains 5 questions and...

Write a shell script of the following: “A Multiple Choice Question that contains 5 questions and each question carries 2 options. Choice will be given by the students. A record file is created each time the script runs to store the answers along with the total marks obtained. The record filename that has date and timing information as well as the student name.

Solutions

Expert Solution

#!/bin/bash
# GNU bash, version 4.3.46
echo "Enter your name"
read n
now=$(date +"%T")
echo "Answe Time : $now"
echo "Student Details : -" >>temp
echo "STUDENT NAME : $n" >> temp
echo "Start time : $now" >> temp
mark
echo -e "Question no 1 : \n====================================="
echo "What is the value of 2+2"
echo "a.4 b.0"
read k
if test "$k" = "a"
then
#echo "right ans"
mark=`expr $mark + 10`
echo "question 1 ans is : a.4 " >>temp

else
#echo "wrong ans"
echo "question 2 ans is : b.0 " >>temp
fi
echo "===================================="

echo -e "Question no 2 : \n====================================="
echo "does a bird fly"
echo "a.Yes b.No"
read k
if test "$k" = "a"
then
#echo "right ans"
echo "question 2 ans is : a.yes " >>temp
mark=`expr $mark + 10`
else
#echo "wrong ans"
echo "question 2 ans is : b.no " >>temp
fi
echo "===================================="

echo -e "Question no 3 : \n====================================="
echo "what is the value of 1/0"
echo "a.1 b.Error"
read k
if test "$k" = "b" 
then
#echo "right ans"
mark=`expr $mark + 10`
echo "question 3 ans is : b.Error" >>temp
else
#echo "wrong ans"
echo "question 3 ans is : a.1 " >>temp
fi
echo "===================================="

echo -e "Question no 4 : \n====================================="
echo "what is the value of root 3*3*3*3"
echo "a.3 b.9"
read k
if test "$k" = "b" 
then
#echo "right ans"
mark=`expr $mark + 10`
echo "question 4 ans is : b.9 " >>temp
else
#echo "wrong ans"
echo "question 4 ans is : a.3 " >>temp
fi
echo "===================================="

echo -e "Question no 5 : \n====================================="
echo "Capital of USA"
echo "a.Washington D.C b.Pheonix"
read k
if test "$k" = "a"
then
#echo "right ans"
mark=`expr $mark + 10`
echo "question 5 ans is : a.Washington D.C " >>temp
else
#echo "wrong ans"
echo "question 5 ans is : b.Pheonix " >>temp
fi
echo "===================================="

#echo "total mark $mark"



echo "Total marks : $mark" >> temp
l="=================================================="
echo $l >> temp 

Related Solutions

QUESTION 1 MULTIPLE CHOICE (20) REQUIRED For each of the following questions, write down only the...
QUESTION 1 MULTIPLE CHOICE (20) REQUIRED For each of the following questions, write down only the letter of the correct answer e.g. 1.6 C. Do not show any calculations. 1.1 The accounting period of Meander Enterprises ends on the last day of February each year. On 28 February 2017, the total of the Rent expense account was R41 100. Rent was paid up to 31 March 2017. Note: Rent expense increased by 10% with effect from 01 September 2016. Which...
Write a shell script that will create a new password-type file that contains user information. The...
Write a shell script that will create a new password-type file that contains user information. The file should contain information about the last five users added to the system with each line describing a single user. This information is contained in the last five lines of both the /etc/shadow and the /etc/passwd files. Specifically, you should produce a file where each line for a user contains the following fields: user name, encrypted password, and shell. The fields should be separated...
(10pts) Write a shell script to display your name to the screen. (10pts) Write a shell...
(10pts) Write a shell script to display your name to the screen. (10pts) Write a shell script to take a directory as an argument and display the contents of that directory (10pts) Write a shell script that takes any command as a parameter and displays help on that command (e.g. the result of the execution of man <command>). (10pts) Write a shell script that requires two file names as parameters and copies content of one file into another without asking...
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt,...
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt, and then run the script. Explain your observations and how you can rectify the behavior.
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt,...
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt, and then run the script. Explain your observations and how you can rectify the behavior.
A student is given 20 multiple choice questions. Each multiple choice question has 4 options &...
A student is given 20 multiple choice questions. Each multiple choice question has 4 options & only one correct answer. The student answers all the questions in a random manner. a) What is the probability the student scores 80% or above? b) What is the probability the student scores 50% or above?
You take a quiz that consists of 5 multiple-choice questions. Each question has 5 possible answers,...
You take a quiz that consists of 5 multiple-choice questions. Each question has 5 possible answers, only one of which is correct. You will randomly guess the answer to each question. The random variable represents the number of correct answers. Construct the probability distribution for this random variable.
Write a complete shell script that first asks the user to enter a URL. The script...
Write a complete shell script that first asks the user to enter a URL. The script should read the URL into a variable named url. The shell script should then retrieve the file associated with the URL by using the curl command. The output of the curl command should be redirected to a file named html_file. The shell script should then use the grep command to search the file named html_file for the word manhattan. Finally, the shell script should...
Write a program in C to grade an n-question multiple-choice exam (for n between 5 and...
Write a program in C to grade an n-question multiple-choice exam (for n between 5 and 20) and provide feedback about the most frequently missed questions. Your program will use a function scan_exam_data to scan and store the exam data in an appropriate data structurer. Use file redirection to input data – do not use fopen() in your code. The first line of input contains the number of students. Second line is number of questions on the exam followed by...
An SAT test has 8 questions, each question having 5 multiple choice answers. If a student...
An SAT test has 8 questions, each question having 5 multiple choice answers. If a student make random guesses for each answer, find the probability that: a)the number of correct answers is 7. b)the number of correct answers is at least 4. c)the number of correct answers is fewer than 3.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT