Compare 2 strings,join 2 strings,length of a given string, Programming Languages

Assignment Help:

W.A.S.S to perform following string operations using menu:

                          i.    Compare two strings.

                        ii.    Join two strings.

                       iii.    Find the length of a given string.

                       iv.    Occurrence of character and words.

                        v.    Reverse the string.

 

Program

 

#W.A.S.S. to perform string operation: compare, concate, find, occurance, reverse

 

echo "1) Compare two strings."

echo "2) Join two strings."

echo "3) Find the length of a given string."

echo "4) Occurence of character."

echo "5) Occurrence of words."

echo "6) Reverse the string."

 

echo -e "Enter the choice.: \c"

read c

 

case $c in

1)       echo -e "Enter string1:\c"

read str1

echo -e "Enter stingr2: \c"

read str2

if test $str1 = $str2

then

            echo "Entered strings are same."

else

echo "Entered string are not same."

fi

;;

 

2)       echo -e "Enter string 1: \c"

read str1

echo -e "Enter string 2: \c"

read str2

str3=`echo "$str1$str2"`

echo -e "Joint string is: \c"

echo "$str3"

;;

 

 

3)        echo -e "Enter the string: \c"

read str

echo -e "Length of the string is: \c"

echo "$str" | wc -c

;;

 

4)        echo -e "Enter the string: \c"

read str

echo -e "Enter the  character to count the occurance: \c"

read ch

len=`echo "$str" | wc -c`

len=`expr $len - 1`

occ=0

while test $len -gt 0

do

tc=`echo "$str" | cut -c$len`

if test $tc = $ch

then

occ=`expr $occ + 1`

fi

len=`expr $len - 1`

done

echo "No.of occurence : $occ"

;;

 

5)       echo -e "Enter the string: \c"

read str

echo -e  "Enter the  word to count the occurance: \c"

read cw

occ=0

for w in `echo "$str"`

do

if test $cw = $w

then

occ=`expr $occ + 1`

fi

done

echo "No.of occurence : $occ"

;;

 

6)        echo -e "Enter the string: \c"

read str

len=`echo $str | wc -c`

len=`expr $len - 1`

result=""

while test $len -gt 0

do

temp=`echo $str | cut -c $len`

len=`expr $len - 1`

result=`echo $result$temp`

done

echo "Reverse string is: $result"

;;

esac

 

Output

1) Compare two strings.

2) Join two strings.

3) Find the length of a given string.

4) Occurence of character.

5) Occurrence of words.

6) Reverse the string.

 

Enter the choice.: 1

Enter string1:mca

Enter stingr2: mca

Entered strings are same.

 

Enter the choice.: 2

Enter string 1: SVIT

Enter string 2: MCA

Joint string is: SVITMCA

 

Enter the choice.: 3

Enter the string: SVIT

Length of the string is:       4

 

Enter the choice.: 4

Enter the string: SEMESTER

Enter the  character to count the occurance: E

No.of occurence : 3

 

Enter the choice.: 5

Enter the string: welcome to svit svit svit

Enter the  word to count the occurance: svit

No.of occurence : 3

 

Enter the choice.: 6

Enter the string: SVIT

Reverse string is: TIVS


Related Discussions:- Compare 2 strings,join 2 strings,length of a given string

programming assignment using perl, This assignment is an individual progra...

This assignment is an individual programming assignment using Perl. It addresses objectives 3, 4, 5 and 8 as listed in the Subject Outline document. The assignment is based on them

Risk - controls and audit tests, Internal Audit has been asked by the State...

Internal Audit has been asked by the State to review the activities of  The Commission on Workforce Development. The Commission was established several years ago by the state legis

No Linux Audible, Why no Audible support for Linux? Maybe they should use a...

Why no Audible support for Linux? Maybe they should use a browser interface?

Define the procedures cons, Show that we can represent pairs of nonnegative...

Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2 a 3 b .

Computers and programming concept, Computers and Programming Concept 1....

Computers and Programming Concept 1. Classify computer systems according to capacity. How they are different from computers according to the classification of technology. Provi

Application for a mid , The assignment has two parts: first you generate a ...

The assignment has two parts: first you generate a simple application for a MID that operates independently of other MIDs. As a second part, the application is extended to keep so

Java source code classes and objects, Design and implement a stringed music...

Design and implement a stringed musical instrument class using the following guidelines: a. Data fields for your instrument should include number of strings, an array of stri

Vb, sir can you help me visual basic 6.0 project solution

sir can you help me visual basic 6.0 project solution

Mathematical expression of linear programming problem, A Consultant Dietici...

A Consultant Dietician provides diet and nutritional advice to clients. A client's diet requires that all the food s/he eats come from one of the four "basic food groups" (chocolat

Java program, Write a program to calculate amount after n number of years b...

Write a program to calculate amount after n number of years by inputting principal at the rate of 8% interest.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd