Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

1. Write a bash script named triangletype that expects three positive whole numbers on the command line, in increasing order. In other words, it should

1. Write a bash script named triangletype that expects three positive whole numbers on the command line, in increasing order. In other words, it should be called like this:

$triangletype 3 12 15

The script checks first of all that there are three numbers and that they are all positive, and increasing in value. If either of these conditions is false, it dis- plays a usage message and exits. Suppose we call the entered numbers a, b, and c, in that order. If the user has entered valid numbers, the script determines whether :

the numbers are not the sides of a triangle (a + b c) the numbers are the sides of an obtuse triangle(a+b>canda2+b2 canda2+b2 =c2) the numbers are the sides of an acute triangle(a+b>canda2+b2 >c2)

Exactly one of these conditions must be true. The script should display a message stating which is true. The message should be at most one line long and should include the numbers and indicate what is true about them. For example:

$ triangletype 3 4 5 3, 4, and 5 are the sides of a right triangle

2

Write a bash script named sum that expects one positive whole number on the command line. The script checks first of all that there is one number and that it is positive. If either of these conditions is false, it displays a usage message and exits.

Your script should implement a for loop to calculate the sum from 1 to the number specified in the command line. Do not use a closed form expression such as n(n+1)/2 to do your calculation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students explore these related Databases questions