Write a program that reads the data from the file mydata.txt

Assignment Help Computer Engineering
Reference no: EM13322753

Write a program that reads the data from the file 'mydata.txt', saves it in an array of structures and finally prints the array of structures to the monitor.

The file 'mydata.txt' is posted on Webcourses with the homework file. This file contains information about computer hard disks (ie: hard disk name, diameter in inch, size in MB, manufacturing year).

In your code, declare a structure called 'hard_disk'. This structure should contain all the information about a hard disk, as described in the file. Therefore it should have these member variables:
? A string called 'name'. Look at the names of the hard disks in the file to decide how large this string
should be.
? A variable of type 'double' called 'size'that will hold the size of the hard disk
? Two 'int' member variables in the structure, one for the 'capacity' and one for the manufacturing 'year'

After declaring the structure, declare an array of 'struct hard_disk' called 'mydisks'.This array should have a size of 6 since there are data about 6 hard disks in the file.

Next, write a loop in the 'main' function that reads the datafrom the file and stores it in the array of disks. Don't print the data in this loop. You can print it for debugging,but your final solution should not print the data in this loop.

Once the array of disks has been filled, write another loop that prints the data from the array of disks. Your output should look like in the figure below. Notice, for the third hard disk in the file, the year is '0'. Therefore, the program prints 'unknown' for this. Your program should take care of this case by comparing the 'year' to '0' and printing 'unknown' if the year is zero.


Finally, remember to close the file pointer.


Include the output that you obtained.
Product     Size(inch)        Capacity(MB)        Year
-------------------------------------------------------
DEC-R81         14.00                 456                1985
Fujitsu             8.00                 130                  1984
Micropolis-RD53 5.25                 85                Unkown
IBM-0361         3.50                320                 1988
Conner-CP-2045 2.50                40                 1990
Integral-1820    1.80                 20                1992

 

Reference no: EM13322753

Questions Cloud

Write c++ program that stops read a line of text : determine what characters , if any, are not displayed by program you ceated for exercise (a)
Find the angular frequency for small oscillations : A mass , m=1.75 kg, is held between two springs having spring constants 30 N/m and 75 N/m respectively, Find the angular frequency, w, for small oscillations
Determine the specific gravity of the wood : If a sample of wood measuring 1.45" x 3.45" x 6" long has a green weight of 8.55 lb. Determine the specific gravity of this wood.
Explain what is the maximum wavelength of light : what is the maximum wavelength of light that can be used to exhibit the photoelectric effect with lithium metal? it requires 279.7 kJ to remove one mole of electrons from Li atoms
Write a program that reads the data from the file mydata.txt : Write a program that reads the data from the file 'mydata.txt', saves it in an array of structures and finally prints the array of structures to the monitor.
Explain the concentration of the sample in moles/l : In a 1cm cuvette, you measure a sample with an absorptivity constant of 10 L/mol•cm. The absorbance of the sample is 0.5. What is the concentration of the sample in moles/L
Calculate the average intensity of the first wave : Electromagnetic wave 1 has a maximum electric field of 55 V/m, and electromagnetic wave 2 has a maximum magnetic field of 1.5 microtesla. Calculate the average intensity of the first wave
Determine the moisture content and the free moisture : A sample of aggregates weighs 400 grams. After drying at 112oF, its weight was 398.5 grams and absorption is 10%. Determine the moisture content and the free moisture.
Explain carbon dioxide makes up approximately : Carbon dioxide makes up approximately 0.04% of Earth's atmosphere. If you collect a 2.4 sample from the atmosphere at sea level (1.00 ) on a warm day (28), how many molecules CO2 are in your sample

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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