Question

In: Computer Science

Answer the same problem as the if statement assignment but use the case statement instead. You...

Answer the same problem as the if statement assignment but use the case statement instead.

You are working for a company that offers driver licence training and you have been asked to write a script that asks your clients how old they are.

If he/she is 16 years old display the message "Please visit our company to take the test!"

If he/she is 15 years old display the message "Please take the training with us to learn how to drive!"

If he/she enters any other answer display the message. "Please visit out website to see our services!"

Name your script "case_statement.sh"

Be sure to include the standard header:

# Created by Your Name

# Assignment name

# Date

Do a screenshot of the code and the output. Submit as a single Word document

Solutions

Expert Solution

The name of the program here is written as main.sh. Please change the name of the program while submitting the assignment.

The syntax of case statements in a bash script is

case "$var" in

case1) #satement

case2) #statements

...

case*) #staements

esac

Code:

#!/bin/bash

echo "How old are you?"

read age #read the age from user input

#perform case statements to print the message based user input

# * indicates other than case 15 and case 16

case "$age" in

16) echo "Please visit our company to take the test!";;

15) echo "Please take the training with us to learn how to drive!";;

*) echo "Please visit out website to see our services!";;

esac

Output:

How old are you?
16
Please visit our company to take the test!

Please refer to the screenshots below for correct indentations


Related Solutions

This problem requires you to use a heap to store items, but instead of using a...
This problem requires you to use a heap to store items, but instead of using a key of an item to determine where to store the item in the heap, you need to assign a priority (key) to each item that will determine where it is inserted in the heap a) Show how to assign priorities to items to implement a first-in, first-out queue with a heap. b) Show how to assign priorities to items to implement a first-in, last-out...
You are required to use only C for this problem. To begin, instead of using two...
You are required to use only C for this problem. To begin, instead of using two different variables for this problem, you are going to define a structure with two members; one representing the feet and the other one representing the inches. We will also use three functions; one to initialize a structure, one to check the validity of its values, and the last one to print them out. First, define your structure. Next, declare a structure of this type...
Assignment problem. Give a small example of an assignment problem statement. Outline an algorithm for solving...
Assignment problem. Give a small example of an assignment problem statement. Outline an algorithm for solving the assignment problem. Is your algorithm polynomial? Explain.
In Assignment 1A, you participated in a “memory game” activity. In this problem, you will answer...
In Assignment 1A, you participated in a “memory game” activity. In this problem, you will answer this question of interest: “Is there an association between the time of day when the activity was performed and how many items were remembered?” Use the memorygame.csv data set posted on Canvas to answer this question of interest. (Note: the number of items remembered will be categorized into two groups. The data set will contain two columns: column 1 is the time of day...
Problem 4 ..... you can use Matlab Using the same initial code fragment as in Problem...
Problem 4 ..... you can use Matlab Using the same initial code fragment as in Problem 1, add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR bandstop filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce the below is the Problem 1 initail code .. you can use it Matlab The following cilab code generates a 10-second “chirp”...
Use the data below to answer the questions in this assignment. You will first need to...
Use the data below to answer the questions in this assignment. You will first need to enter the following data in SPSS with “age” and “hours” as your variable names. Age and Hours on Computer Data Age (X): 24, 23, 23,25,27, 21,21,30,21,29 Number of hours on spent on computer per week (Y): 14,24,18,23,19,23,16,10,6,15 This question is only being used to describe the data set. In the box below you only need to enter 0. Run a correlation analysis in SPSS...
Write a case you can use PCR to solve the problem and also write a case...
Write a case you can use PCR to solve the problem and also write a case you cannot use PCR to solve to problem
This assignment is the same for both Florida & non Florida students. This problem requires the...
This assignment is the same for both Florida & non Florida students. This problem requires the student to develop a simple budget. At the end of the course, the student will receive a STAR for completing this assignment. This assignment must be completed in either MS Excel or in with a MS Word table* Budget Case Problem Meadow Lake Elementary will receive 600 additional students next fiscal year. This increase in student enrollment will raise the school over the number...
Assignment 1: Case Study #1 Overview Throughout this course, you’re learning how to use problem-solving and...
Assignment 1: Case Study #1 Overview Throughout this course, you’re learning how to use problem-solving and self and social awareness skills to practice the key concepts of psychology. You’re discovering how self and social awareness and problem-solving work together to help you understand the perspectives of others, examine situations objectively, and use evidence to develop and make decisions. With this case study assignment, you’ll have the chance to put your skills to work! Read the case study below and use...
For this homework assignment, you will use the google trends to answer the following questions: 1....
For this homework assignment, you will use the google trends to answer the following questions: 1. Use https://www.google.com/trends/ (Links to an external site.)Links to an external site. to find search trends for terms: a. "iPhone X", and b. "iPhone 8 Plus" between May 1, 2017 to Jan 1, 2018. 2. Summarize the data and present your findings. Please take screenshots of the results from Google Trends and reference these screenshots when you present your findings. Create a Microsoft Document for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT