Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting.

Similar presentations


Presentation on theme: "1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting."— Presentation transcript:

1

2 1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting for input and echo printing (28-29) –Reading and Writing files (30-32) –Detecting I/O failure Run program Frame and add echo printing to confirm the input data before displaying results Add File I/O to the program Frame

3 2 Lab Exercise Demo Due March 7 Worried about our calorie intake, we would like to develop a program that reads the dinner items from a file and saves their names and individual calorie count, followed by total count of calories in a file. If the total calorie count is more than 1,000, a warning is displayed. On the following slides, a sample input data file is shown followed by the expected output file contents.. Take filename at runtime and warn the user on file opening error.

4 3 Sample Input Here are the contents of a sample input file Onion Soup 20 Beef Roast 6 Oz 410 Brown Rice 1 serving 230 Peach Pie One piece 405 Sweetened Instant Tea 85

5 4 The contents of output file Onion Soup 20 Beef Roast 6 Oz 410 Brown Rice 1 serving 230 Peach Pie One piece 405 Sweetened Instant Tea 85 ========================== The total count of calories in your dinner is 1150 Please avoid such feasts

6 5 File Handling Errors Please accept the input file’s name at runtime Your program should issue meaningful error messages when the file I/O stream enters fail state


Download ppt "1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting."

Similar presentations


Ads by Google