Explore BrainMass
Share

Write a shell script that prints the following menu (Unix)

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Write a shell script that prints the following menu
Welcome to My Simple Mathematica
a) Choose 'a' for Fibonacci Series
b) Choose 'b' for Prime Numbers

Please make your choice [a or b]:
Once the user enters 'a' or 'b' perform the appropriate calculation and print the series. Limit the series by requiring the user to provide the upper limit number.
After printing the series prompt the user if they wish to continue. A positive response (Yes) prints the menu again, and a negative response (no) exits the program.

generate 7 fibonacci numbers i.e. 1 1 2 3 5 8 13

© BrainMass Inc. brainmass.com March 21, 2019, 7:06 pm ad1c9bdddf
https://brainmass.com/computer-science/algorithms/write-shell-script-prints-following-menu-unix-279767

Solution Preview

This is written in bash. It wouldn't take too much effort for you to convert it to csh if thats what you need.

#!/bin/bash

function fibonacci {
# This is implemented with the limit as the highest value to obtain.
# The question was ambiguous about whether this was supposed to be a
# limit or a count. Changing it to a count is very straightforward.

first=0
second=1

...

Solution Summary

The expert writes a shell script that prints a menu for Unix.

$2.19