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

  What would be the transmission rate

Supposed two TCP connections are present over some bottleneck link of rate R bps. Both connections have a huge file to send (in the same direction over the bottleneck link). The transmissions of the files start at the similar time. What is the tra..

  Integrity of data entered into a database

What is the relationship between quality and integrity of data entered into a database and the resulting effect on the quality of patient care.

  Describe the four different types of joins

Describe the four different types of "joins" and provide examples of how you would use each.

  What is tcp hijacking

What is TCP hijacking and how is it done? What are some defenses against it.

  Develop the finite difference approximation of fick second

Develop the finite difference approximation of Fick's second law of diffusion in polar coordinates. Write a MATLAB program that can be used to solve the following problem.

  Consider database security from a variety of perspectives

Share experiences have you had in terms of user security in past jobs or as a student? Do you feel the user security was effective in those situations? What will you have done differently in light of what you've learned about data security.

  Write down an application that displays a menu

Write down an application that displays a menu.

  Mutual authentication and key establishment protocol

Assume a server-assisted mutual authentication and key establishment protocol. Suppose that Alice and the Server share the pairwise symmetric key KAS; however Bob and Server share a pairwise symmetric key KBS.

  Board of your business it network for discussion

In another year, after all projects are completed, you plan to convert back to a volunteer basis with AllTechComm, and to find out more profitable employment, preferably with a major corporation. You are doing all of the research and networking yo..

  Network that contains several netware 4.11 servers

Your company has a network that contains several NetWare 4.11 servers and uses IPX as the routing protocol. Each of the network segments has as a minimum  one NetWare server on it. Which of the following responds to a Get Nearest Server (GNS) reque..

  Define how a databses management system

describe how a databses management system (DBMS) and data mining can help a motor vehicle maintenance center improve its services, and what tables would be needed in such a database. Also what additional way can the DBMS and data mining be used to..

  What will be formula of digital certificate of the server

Point out what will be the formula of digital certificate of the server N. we denote the public and private keys of server N as K+ ,N KN, and public or private keys of CA are denoted as K+ CA KCA.

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