Tuesday, August 4, 2015

Chapter 4 Solutions (2-21)

2. Distance Traveled














3. Distance File











4. Pennies for Pay















5. Letter Counter









6. File Letter Counter






























Write a program that asks the user for the name of a file. The program should display only the first five lines of the file's contents. If the file contains fewer than live lines, it should display the file's entire contents.









Lets just say it works because I don't want to screen shot everythign.

14. Line Numbers
Write a program that asks the user for the name of a file. The program should display the contents of the file with each line preceded with a line number followed by a colon. The line numbering should start at 1. 










15. Uppercase File Converter 


Write a program that asks the user for the names of two files. The first file should be opened for reading and the second file should be opened for writing. The program should read the contents of the first file, change all characters to uppercase, and store the results in the second file. The second file will be a copy of the first file, except that all the characters w ill be uppercase. 
this is the upper.txt file




No comments:

Post a Comment