NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#!/bin/bash
function task1(){
read -p "Please enter the first range:" range1
read -p "Please enter the second range:" range2
sum_odd=0
sum_even=0
howmany_even=0
howmany_odd=0
while [ $range1 -le $range2 ]; do
triangular_num=$((range1*(range1+1)/2))
if [ $(($triangular_num % 2)) -eq 0 ]; then
sum_even=$(($sum_even + $triangular_num))
echo "$triangular_num (This number is even)"
((howmany_even++))
else
sum_odd=$(($sum_odd + $triangular_num))
echo "$triangular_num (This number is odd)"
((howmany_odd++))
fi
((range1++))
done
echo "Sum of even numbers: $sum_even."
echo "Sum of odd numbers: $sum_odd."
echo "There are $howmany_even triangular even numbers."
echo "There are $howmany_odd triangular odd numbers."
}
function task2(){
read -p "Input Number: " value
read -p "Input Desired Number of Operations: " count_value
read -p "Input Real Integer: " x
count=0
while [ $count -le $count_value ]; do
product=$(( value * (value + 1) ))
echo "Product: $product"
((count++))
((value++))
if [ $((product % x)) -eq 0 ]; then
echo "x is a factor of the product"
else
echo "x is not a factor of the product"
fi
done
}
function task3() {
a=$1
b=$2
c=$3
n1=$4
n2=$5
product=$(( (a*n1**3 + b*n1 + c) * (a*n2**3 + b*n2 + c) ))
echo "Product of the first and last term: $product"
if (( product % 4 == 0 )); then
echo "Product is a multiple of 4"
else
echo "Product is not a multiple of 4"
fi

for ((n=n1; n<=n2; n++)); do
term=$(( a*n**3 + b*n + c ))
echo "Term $n: $term"
done

}
read -rp "Please enter a password:" password
if [[ $password == "COMP1236" || $password == "Comp1236" ]]; then

echo "Welcome to our application menu! Please proceed by choosing one of our options below."
echo "T or t for Task 1"
echo "N or n for Task 2"
echo "S or s for Task 3"
while true; do
read -p "Enter your choice (T/N/S): " choice
case "$choice" in
[Tt])
echo "You have selected Task 1."
task1
read -p "would you like to continue (Y/N):" Y || N
if [[ "$continue_choice" != "Y" && "$continue_choice" != "y" ]]
then
continue
else
exit 1
fi
;;
[Nn])
echo "You have selected Task 2."
task2
read -p "would you like to continue (Y/N):" Y || N
if [[ "$continue_choice" != "Y" && "$continue_choice" != "y" ]]
then
continue
else
exit 1
fi
;;
[Ss])
echo "You have selected Task 3."
echo "Task 3: Sequence Terms"
read -p "Enter the value of a: " a
read -p "Enter the value of b: " b
read -p "Enter the value of c: " c
read -p "Enter the starting position (n1): " n1
read -p "Enter the ending position (n2): " n2
task3 $a $b $c $n1 $n2
read -p "would you like to continue (Y/N):" Y || N
if [[ "$continue_choice" != "Y" && "$continue_choice" != "y" ]]
then
continue
else
exit 1
fi
;;
*)
echo "Invalid choice. Please enter one of the listed options."

;;
esac
done
else
echo "Wrong password"
exit 1
fi
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.