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...
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”...
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
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...
COST ACCOUNTING ASSIGNMENT – CASE STUDY Read the case study below and answer the questions that...
COST ACCOUNTING ASSIGNMENT – CASE STUDY Read the case study below and answer the questions that follow. Ma Baker produce a mini-kitchen called Small Cook, which is enjoying extensive popularity amongst young children. The following data is available for the month: Selling price (per unit) R116 Units in opening inventory 600 Units manufactured 2 550 Units sold 3 050 Units in closing inventory 100 Variable costs per unit: Direct materials R12,00 Direct labour R50,00 Variable manufacturing overhead R6,50 Variable selling...
There are two stories to read and answer questions on in this week's discussion assignment. Case...
There are two stories to read and answer questions on in this week's discussion assignment. Case #1: Use the following story to complete the questions below: Jessica is a 50-year-old married woman with a genetic autoimmune deficiency; she has had recurrent infective endocarditis. The most recent episodes were a Staphylococcus aureus infection of the mitral valve 16 months ago and a Streptococcus viridans infection of the aortic valve 1 month ago. During the recent hospitalization, an echocardiogram showed moderate aortic...
In this assignment you are going to use the menu you created in Assignment 1 to...
In this assignment you are going to use the menu you created in Assignment 1 to test both your Double and Integer classes. You should add functionality to the menu to allow you test the add, sub, mul, div functions for instances of both classes You are going to have make a modification to your menu class. Currently it uses an array to hold a fixed amount of menu items. While this may be OK for most applications we want...
C++ Assignment Inheritance This uses some single arrays of doubles. We can use Vectors instead if...
C++ Assignment Inheritance This uses some single arrays of doubles. We can use Vectors instead if we want! Choice either vectors or arrays either one is fine We will implement a classic Inheritance hierarchy. A simple console based interface is all that is needed. Build your classes first, each in their own .h and .cpp files, then test them with the simple main method provided below. Phase 1 : Here is the following set of classes you will implement and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT