Copyright © – Sudharsan Iyengar

 

CS – 234.                    Lab 6 – Iteration continued    10/14/24

 

Write a class, that has methods to do the following:

 

a)     Requests an integer value from the user and outputs:

a.      all the digits separated by a space.

b.     sum of all the digits. If this sum is greater than 10 then this process is repeated until the sum is less than 10.

 

Ex:                              user inputs 8886

 

                              Output should look like

 

                                          8 8 8 6 = 3 0 = 3

 

b)     Requests a word from the user and outputs:

a.      the word with all letters capitalized.

b.     the word with only the first letter capitalized.

 

Ex:                  User inputs WiNona

 

                  Output should look like:

 

                  WINONA

                  Winona

 

c)     Requests a sentence from the user and outputs:

a.      the words in the sentence – one word per line

b.     the number of words in the sentence

 

            Ex:                  Use inputs       Winona is a beautiful city in Minnesota

 

                                    Output should look like

 

                                    Winona

                                    is

                                    a

                                    beautiful

                                    city

                                    in

                                    Minnesota

           

                                    The sentence has 7 words.

 

d)     That opens an input file “lines.dat” that contains many sentences, one sentence per line, and outputs for each line a) the line number, b) the sentence, c) the number of words in the sentence and d) the number of vowels in the sentence.