Ask Computer Network & Security Expert

Getting started

Change into the cse220 directory. Create a new directory called lab14.

Change into the new directory. Implement the program below in your lab14 directory.

C Structs and Enums

Struct variables

Create a header file capacitor.h.

Protect your header using #ifndef directive.

Define a struct with tag Capacitor that holds the following information about a capacitor: Model number (e.g. 11-123U), capacitance (e.g. 1000 uf), voltage (e.g. 2.5 V), cost ($6.50)

Create your main program file capacitorsInfo.c that uses the header file you just declared. Declare two variables of type struct Capacitor and populate them with the following values: First variable: model is 11-123U, capacitance is 100, voltage is 25 and cost is $6.00

Second variable: model is 65T91a, capacitance is 22000, voltage is 20 and cost is $25.00

Print the the model number of the first capacitor and the voltage of the second.

Create a makefile to build your program. Make sure it compiles and runs without errors. Remove your print statements.

Struct Array

Add a third Capacitor variable and initialize it from values entered by the user. Use fgets when reading the model number to make sure you don't exceed the size of your model number array.

Print to the standard output the members of the third capacitor and to make sure the capacitor is populated correctly.

Declare an array of Capacitors of size 4 and copy the three capacitors you created to the array. Populate the fourth element of the array from user input.

Manipulation with Functions

Add to capacitor.h the prototype of function displayCapacitorInfo that takes a capacitor as input parameter and prints its details in the following format:

Capacitor 11-123U:

*  Capacitance 100 uF

*  Voltage: 25 V

* Cost: $25.00

Add the function definition in a corresponding C file capacitor.c. Call your function in the main file on all members of the array.

Using typedef

Change the struct definition from using tag name to using typedef. Modify your program to work properly with the new definition.

Add (to capacitor.h/capacitor.c) a function largestCapacitance that takes as input an array of Capacitors and returns a pointer to the Capacitor with the largest capacitance.

Call largestCapacitance on your array and add statements to print the cost of the capacitor returned by the function.

Using Enum

In the header file capacitor.h, define an enumeration CapType with the following values: Ceramic, Aluminum, Film, Supercapacitor

Add a new member, capacitor type, to your struct Capacitor.

Update the capacitor type member of all elements of the array to a type of your choice. Update the displayCapacitorInfo function to print the capacitor type as well.

Saving/Loading from a File

Add (to capacitor.h/capacitor.c) the following functions:

- saveCapacitor: takes as parameters a capacitor and a filename and saves its member variables into the file given

- saveCapacitors: takes as parameters an array of capacitors and a filename and saves all capacitors into the file given, each capacitor on a separate line

- loadCapacitor: takes as parameter a filename and returns a capacitor. The function should populate the capacitor data from the given file.

Test your functions in your main program by:

- Saving the first capacitor into the file cap1.txt

- Saving the capacitor array into the file allCaps.txt

- Loading data from cap1.txt into a new capacitor variable

- Printing the values of the newly created capacitor to the screen

Handin

Submit through the handin system the following files: capacitorsInfo.c, capacitor.h, capacitor.c, makefile

The "handin" system has options to allow you to review your files online and to download them. You Should always verify that you submitted the correct files and they were received by the handin system. You can submit files as many times as you like for a particular assignment. Handin will only keep the last version of each file. Remember to submit your files prior to the deadline as you won't be able to use handin if the deadline has passed.

Computer Network & Security, Computer Science

  • Category:- Computer Network & Security
  • Reference No.:- M91761309
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Computer Network & Security

Security challenges in emerging networksassignment

Security Challenges in Emerging Networks Assignment Description The purpose of this assignment is to develop skills to independently think of innovation. In this assignment students will first learn how to develop knowle ...

Security challenges in emerging networksassignment

Security Challenges in Emerging Networks Assignment Description The purpose of this assignment is to develop skills to independently think of innovation. In this assignment students will first learn how to develop knowle ...

Security challenges in emerging networksassignment

Security Challenges in Emerging Networks Assignment Description The purpose of this assignment is to develop skills to independently think of innovation. In this assignment students will first learn how to develop knowle ...

Security challenges in emerging networksassignment

Security Challenges in Emerging Networks Assignment Description The purpose of this assignment is to develop skills to independently think of innovation. In this assignment students will first learn how to develop knowle ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Assignment descriptionproject scope a typical network

Assignment Description Project Scope: A typical network layout diagram of a firm is given below for illustrative purposes only. The service requirements are enclosed. Figure. Network layout of a firm Service requirements ...

Assignment descriptionproject scope a typical network

Assignment Description Project Scope: A typical network layout diagram of a firm is given below for illustrative purposes only. The service requirements are enclosed. Figure. Network layout of a firm Service requirements ...

After reading this weeks materials please respond to two 2

After reading this week's materials, please respond to TWO (2) of the following questions. AND PROVIDE CITATION IN APA 1. Describe the differences between bus, ring, star and mesh topologies. 2. Explain the TCP/IP Model ...

The abstract should not be more than 250 words describe

The abstract should not be more than 250 words. Describe your project, focusing on research questions and research method for next stage of the project. 1. Introduction [The introduction should describe what the project ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As