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
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
|