Question
A file Numbers.txt (given below) contains an unknown number of both negative and positive integers. 56 -9 -11 23 1 41 23 -54 3 21
A file Numbers.txt (given below) contains an unknown number of both negative and positive integers.
56
-9
-11
23
1
41
23
-54
3
21
-8
Create a program that reads the numbers from the file, counts and sums all negative numbers and separately all positive numbers (zero is considered positive). Your program should display the final count and sum for these numbers. All these values can and should be computed within one reading pass through the file.
Sample run (not for the given file):
Processing file -- please wait Negative count: 12 Negative sum: -231 Positive count: 9 Positive sum: 145
Hint: follow examples on pages 298, 299 for file processing. Pay close attention to file open errors.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started