This two-part lab deals with reading numerical data from a binary file named NBdata.bin. The main reason for using binary rather than text files is that they require less memory and are much faster. The program will read the integer data in binary form and calculate two related quantities: the odd geometric, and the even harmonic means. Important: (1) Although the text file is much longer, the program will only read a fixed number of records, N to provide variability for testing purposes. (2) It may be easier to read all N elements from the file and store them into an integer array since the program will need to access them later. (3) The file will contain only positive integers. (4) Prompt the user for this fixed number of elements N to read from the file. This number will be between 3 and 100. (Your program does not need to check the input). Use the format below. Enter N: [...] Part I: Open the binary file named NBdata.bin for readig. The file is stored internally. Prompt the user how many numbers (N) to read. Read all these N elements from the file and output the odd geometric mean from those elements. The odd mean will only use the numbers that are odd. For example if N = 5 and the file has the elements 12 3 4 8 1 then the program will only use the odd numbers 3 and 1. If there are no odd numbers the answer will be 0. (See formula in the attached file) Use the format below. 50 Points Odd G Mean = [...] Part II: Update the code from part II and also output the even harmonic mean of the N elements. This even means will only use the even numbers. For example, if N = 5 and the file has the elements 12 3 4 8 1 then the program will only use the even numbers 12, 4, and 8. If there are no even numbers the answer will be 0. (See the formula in the attached file) Use the format below. 50 Points Even H Mean = [...] Notes: (1) The […] should be replaced with the correct values based on the input entered by the user or respective output. (2) Although the file has only integers both mean values will likely be decimals so declare them as double variables. (3) Do not forget to close the file at the end of the program.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

This two-part lab deals with reading numerical data from a binary file named NBdata.bin. The main reason for using binary rather than text files is that they require less memory and are much faster. The program will read the integer data in binary form and calculate two related quantities: the odd geometric, and the even harmonic means.

Important: (1) Although the text file is much longer, the program will only read a fixed number of records, N to provide variability for testing purposes. (2) It may be easier to read all N elements from the file and store them into an integer array since the program will need to access them later. (3) The file will contain only positive integers. (4) Prompt the user for this fixed number of elements N to read from the file. This number will be between 3 and 100. (Your program does not need to check the input). Use the format below.

Enter N: [...]

 

Part I: Open the binary file named NBdata.bin for readig. The file is stored internally. Prompt the user how many numbers (N) to read. Read all these N elements from the file and output the odd geometric mean from those elements. The odd mean will only use the numbers that are odd. For example if N = 5 and the file has the elements 12 3 4 8 1 then the program will only use the odd numbers 3 and 1. If there are no odd numbers the answer will be 0. (See formula in the attached file) Use the format below. 50 Points

Odd G Mean = [...]

 

Part II: Update the code from part II and also output the even harmonic mean of the N elements. This even means will only use the even numbers. For example, if N = 5 and the file has the elements 12 3 4 8 1 then the program will only use the even numbers 12, 4, and 8. If there are no even numbers the answer will be 0. (See the formula in the attached file) Use the format below. 50 Points

Even H Mean = [...]

 

Notes:
(1) The […] should be replaced with the correct values based on the input entered by the user or respective output.
(2) Although the file has only integers both mean values will likely be decimals so declare them as double variables.
(3) Do not forget to close the file at the end of the program.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education