write a short program that asks the user whether or not they would like to open
ID: 3638702 • Letter: W
Question
write a short program that asks the user whether or not they would like to open a file containing numbers or enter values from a keyboard. Based on their selection, do the following:FILE option: prompt the user for the name of the file, open it, read the values in the file, and print out the sum of the numbers in the file (be sure to print an error message if the file contains non-numerical values)
KEYBOARD option: prompt the user for the list of numbers and let them know what to do when they have entered the entire list. Create a list containing the sequence of numbers that the user entered, print the list, and print the sum of the numbers in their list. Decide how you want to handle issues with operator error (if they accidentally type a letter instead of a number, etc…).
Because you have more control over the design and function of your program, be sure to include your requirements in the comments. Review the sample code in this assignment, sample code that has been posted on icon and discussed in class, your solution to the previous homework assignment, and sample code discussed in the lab to help in writing this program. It might be easier to write two separate programs first…one that takes care of the FILE option (including how to handle potential errors…like an empty file, a file that contains alphanumeric data, or other problems that you can think of) and another program that takes care of the KEYBOARD option (including how to handle potential errors, like alphanumeric data, etc..., and how the user will indicate that they are done). Then you can combine the two programs based on the user input to a question. Be sure to COMMENT YOUR CODE!
Explanation / Answer
Hello. We cramster experts have decided not to provide any answer publicly. That is because people are copying from older threads which have public answers. Hence we'll only send the answer after you rate. So please rate a Lifesaver and I'll send the solution to your inbox or email. You've got no other option to get the answer, because no one is going to give you the answer over here. You need not worry as I have the solution ready in my notebook. Hope you rate me :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.