1. Input a positive integer N and compute and print
the sum
2. (String to Integer conversion) The user inputs a string
that represents an integer number (positive or negative). Write
a function int StringToInt( string s ) that returns the integer
that the string represents.
You have to check if the string indeed represents a number (in particular, no characters other than digits and '-' are allowed in the string, and '-' can only occur in the leading position). Your function must print an informative error message and exit if the input string is invalid.
Your main function should prompt the user for strings, convert them to integers and print the results, until the user enters a string which does not correspond to a number, or an empty string.
Extra credit: write a function double StringToDouble( string s ).
3. Write a program that prompts the user for a word and the name
of a text file, then opens the file and counts how many times that word
occurs in that file (and prints the count). Then prompt the user for
another word and count how many times it occurs in the same file, etc.
Continue until the user enters the word ``bye''.
4. Extra credit. Write a program that counts the number of
different words in a text file.