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

  How many bits are needed to address

How various bits are required to address a 1M × 8 main memory if Main memory is byte-addressable.

  What are the implications for management

Reduction in cost of hardware with time.What are the implications for management of each of the trends.

  How the company can decrease the threats

This solution explores security threats faced by a company when implementing a wireless network. In particular, this solution utilizes a case study to define the threats faced by the company and extrapolates on how the company can reduce the threa..

  Design a class diagram for the ticket-processing system

Design a class diagram for the ticket-processing system

  Prolog as programming language for logic

Utilizing the Prolog as the programming language for the LOGIC, form the relevant command in order to perform the following tasks. Prolog Lists - A list is either empty or it comprises of the first element (head) and a tail, which is a list itself.

  Write a program displays the sum, average, product

Write down a Visual Basic application that inputs three integers from the user and displays the sum, average, product, smallest and largest of the numbers in an information message dialog.

  Configuration management and control in industry standards

There is no specific word count or anything; I just need to know a little bit about it.

  Common runtime libraries such as visual studio.net

should C++ programming language be extended to contain an XML editor and parser as is the case for the Java® programming language, or should this be built into the Integrated Development Environment (IDE) that supports the programming language?

  Deducing an expression for pp

Utilizing the information above, deduce an expression for the PP, and provide comment on resulting expression. Also, what the ATM services would you utilize in order to obtain the best possible performance?

  Make a database in ms access

create a database in MS Access and a set of reports to support a business . The following business rules should be addressed.

  What are the advantages of using the scsi devices

What will be different about performing a hard-drive-to-tape backup with IDE devices and with SCSI devices? What are the advantages of using SCSI devices over IDE devices for the backups.

  Why database re-engineering and redesign is required

define what should be done when adding tables and relationships for normalization.

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