Program containing variable length groups of data

Assignment Help Biology
Reference no: EM1388414

Create a program that will read a file containing variable-length groups of data and report the average value of each group.

Begin by using a text editor to store the following data in a file named group.dat:
5 96 87 78 93 21 4 92 82 85 87 6 72 69 85 75 81 73

The data is arranged in the file so that each group of numbers is preceded by the number of data items in the group. Thus, the first number in the file, 5, indicates that the next five numbers should be grouped together. 
The number 4 then indicates that the following four numbers are a group, etc.
Write a C++ program to read the file group.dat, calculate the average of each group, and display it on the screen. [Hint: use nested loops]

Your program must do the following:
• Prompt the user and enter the filename from the console
• Open the file and confirm that the file opened correctly. If not, inform the user and continue to solicit a filename until it opens correctly or the user indicates he/she does not want to continue 
• Display the average value for each of the groups in the file

Note: Your program should work for any data file formatted in this fashion. You do not know how many groups of numbers will be included. To check this, you should create another test case with a different number of groups.
Example:
Enter filename: groups.dat
File groups.dat failed to open.
Abort? (y/n): n
Enter filename: group.dat
Group 1 has 5 numbers. Average = 75.00
Group 2 has 4 numbers. Average = 86.50
Group 3 has 6 numbers. Average = 75.83

Reference no: EM1388414

Questions Cloud

Determine the components of the force-close fitting hole : In the design of the robot to insert the small cylindrical part into a close-fitting circular hole, the robot arm must exert a 90-n force p on the part parallel to the axis of the hole as shown. Determine the components of the force which the part..
Program-compute monthly interest-print next balance for sav : Set annual interest rate to 4% then compute monthly interest and print next balance for both savers. Then set annual interest rate 5%. Compute next month interest and print next balance for both savers.
Having separate payroll departments in each division : Having separate payroll departments in each division of a divisional structure is an example of which of the following? Efficiency, because payroll departments compete.
Private health insurance-government sponsored health care : With respect to financing, Critically discuss the main differences between private health care insurance and government sponsored health care for persons over age 65 (Medicare)?
Program containing variable length groups of data : Create a program that will read a file containing variable-length groups of data and report the average value of each group.
Probability regarding the arrival of bus : Assume that a study of 500 randomly selected school bus routes showed that 480 arrived on time. Is it "significant" for a school bus to arrive late?
Ethical principles that should guide budget development : Critically discuss the ethical principles that should guide budget development? If a department is consistently going over budget, yet the department's management is sound, Discuss some of the things that could be causing the problem?
Finding possible pathways : Suppose that a series of compounds has been found in  Neurospora . Compounds A-F appear to be members of an enzyme pathway.
Examine hard-to-obtain data from two separate databases : You are interested in examining some hard-to-obtain data from two separate databases. Each database comprises numerical values - so there are 2n values total

Reviews

Write a Review

Biology Questions & Answers

  Laws of mendelian inheritance of cyctic fibrosis.

A rare recessive allele inherited in the Mendelian manner, results in the disease Cystic Fibrosis. Assume a man who is phenotypically normal, and whose mother was normal however his father had cystic fibrosis, marries a woman who is also phenotypi..

  Define how prokaryotes and eukaryotes provide different

define how prokaryotes and eukaryotes provide different. What does each category tell you about evolution; pick one from an early era and one from today or recent times.

  Strategy for a virus

Describe these strategies. What are the advantages and disadvantages of each strategy for a virus? Give an example of a specific virus and how it follows one of the strategies.

  The food containers are left open at room temperature

Would you expect Dissolved Oxygen in water taken from the stream entering a lake to be higher or lower than Dissolved Oxygen taken from the lake itself? Give details.

  Immunology based multiple choice questions

Hematopoietic stem cells cultured in the presence of which receptor differentiate into T cells rather than B cells?

  Describe the role of this enzyme in honey

Glucose oxidase is an enzyme that can be used for measurements of glucose levels by combining this reaction with an oxygen probe.

  What advantage will heterozygotes have over the homozygotes

What advantage will heterozygotes have over the homozygotes. Why selection inevitably favors any gene that is good at getting into the next generation, regardless of whether that gene helps or hurts the ecosystem, the species, the group, or even the ..

  Find out the order of the genes

sketch the chromosomes of the parents and the F1. analyse interference and say what you think of its significance.

  Assume n-butylmalonate is added to an aerobic

Assume n-butylmalonate is added to an aerobic suspension of kidney cells using glucose exclusively as fuel. Predict, with description, the effect of this inhibitor on.

  Determine the ultimate effect in an xy human

Determine the ultimate effect in an XY human with its SRY gene mutated, many mating were made among all-white cats. The progent from these mating showed the following phenotypic frequency,

  Describe the physical changes that would occur in sim

What effect might this have on cell lineages during development. Describe the physical changes that would occur in SIM medium if you inoculated an organism that was negative for hydrogen sulfide but positive for indole production and motility.

  Suggest a hypothesis to explain this behaviour

Eastern tent caterpillars live in sizable groups in silk nests, or tents, which they construct in cherry trees. They are among the first insects to become active in the spring, emerging very early in the season-a time while daily temperature fluctuat..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd