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...
For the prelab assignment, you may not use the if statement nor may you use the...
For the prelab assignment, you may not use the if statement nor may you use the if/else statement. You are to write a program that calculates factorials from 1 up to and including a maximum number given by the user. Because factorials get large quickly, use long unsigned int as the type for the number entered by the user as well as the factorials you are calculating. If the user enters a 0, print an error message. Then ask if...
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...
HOW CAN I USE a string instead of array tries and res on this assignment, with...
HOW CAN I USE a string instead of array tries and res on this assignment, with out impacting the program or modifying too much on conditions  check code bellow import java.util.Scanner; import java.util.Random;//starter code provided public class inputLap { public static char roller; public static String playerName; public static int printed=0; public static int rounds=8,lives=0,randy; public static int tries[]=new int[4];//use arrays to store number of tries in each life public static int res[]=new int[4]; public static String getName(String aString){ Scanner sc=...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT