Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

PROBLEM

You are to create a program that allows a user to view the voltage, current and impedance for each component and the total in either the parallel circuit (a) or series circuit (b). The program will ask the user for the circuit type, the source voltage, the frequency, the number of components, and the values of each component. The two circuits are shown below:

1969_Figure.jpg

FUNCTION PROTOTYPES AND INCLUDES

1. You must include the stdio.h and stdlib libraries
2. The following function prototypes are to be used:

2314_Figure1.jpg

a. The first two are described below
b. The last four will be developed in lab5, you need to alter the types from floats to doubles
c. You can change the naming
d. You cannot change the types

FUNCTION - MAIN

1. The program prints to the screen the student number, student name and the assignment number. This is enclosed by
double asterisks. Ensure you follow the below format.

**3777777    John Smith Assignment 2**

2. The program asks the user which circuit they want to evaluate, the frequency in hertz, the source voltage and the number of components. And stores the results appropriately. All of these values are positive integers. When asking for the number of components, the type of circuit should be specified as shown below.

a. You can assume the user enters valid values for frequency, voltage and number of components.
b. You must handle the case where the user enters an incorrect value for the type of circuit and give a message to the user. (No example given, a single line for ‘invalid message' to user ending with a newline. The message is up to you, but must be appropriate)

Do you want to create a 1.parallel or 2. series circuit evaluation? 1

Enter the frequency in Hertz of the source:60

Enter the source voltage :12

How many components are in parallel:3

3. The program creates an array of pointers to doubles (hint: use [ ]), the array is of length 6

a. Then using a for loop dynamically allocate memory (malloc) for each of the pointers an array of size sizeof(double) *(number of components + 1)
b. This is the result table
c. The program stores the source voltage in the array as shown below

result_table[4] [number_of_components] = source_voltage;

result_table[5] [number_of_components] = 0L;

Impedance component 1 -

Real part

Impedance component 2 -

Real part

...

Impedance component n -

Real part

Total Impedance  - Real part

Impedance component 1 -

Imaginary part

Impedance component 2 -

Imaginary part

...

Impedance component n -

Imaginary part

Total Impedance  - Imaginary part

Current component 1 -

Real part

Current component 2 -

Real part

...

Current component n -

Real part

Total Current - Real part

Current component 1 -

Imaginary part

Current component 2 -

Imaginary part

...

Current component n -

Imaginary part

Total Current - Imaginary part

Voltage component 1 -

Real part

Voltage component 2 -

Real part

...

Voltage component n -

Real part

Total Votage/Source Voltage - Real part

Voltage component 1 - Imaginary part

Voltage component 2 -

Imaginary part

...

Voltage component n -

Imaginary part

Total Votage/Source Voltage - I

maginary

part

4. The program creates a pointer to ints and dynamically allocates memory for an array of length number of components. This will store the component types.

5. The program creates a pointer to doubles and dynamically allocates memory for an array of length number of components. This will store the size of the components.

6. For each component, the program asks the user to enter the type of component and the value of that component. When asking for the size, the correct units must be shown (Ohms, Farads and Henrys).

a. The storing of the component types and values must be done using pointer arithmetic in this section. (Refer to lab 6 and additional material)

b. You can assume the user enters valid values components (1,2 or 3) and their values (positive values)

2311_figure2.jpg

7. Calculate the impedance values by calling the calculate_impedance function. (Described in section below)

8. Calculate the total current values for both the real and imaginary parts and store appropriately (Ohms law I=V/Z)

9. Calculate the voltages and currents of all components, and store appropriately. (Hint. Refer to background information - Ohms Law. Parallel and series will have different equations)

10. Call the print_results function to print out the results table (Described in section below)

11. End the program appropriately.

FUNCTION - CALCULATE_ IMPEDANCE

1. Calculate the impedance for both real and imaginary part for each component using a for loop with an if, else-if, else statement in the loop. And store the results in the results_table (Hint. Refer to background information - Impedance. Resistors, Capacitors and Inductors have different equations)
2. Calculate the total impedance for both real and Imaginary parts. And store the results in the results_table (Refer to additional material if new to summation)
a. Hint: (One possible implementation)
i. Create temporary variables to store the current sum (for both complex and real parts) and initialize to 0.
ii. Create variables to store the total impedance (both for complex and real parts).
iii. Then if the circuit is series:
1. Iteratively add to these for each impedance values.
2. The sum is the total impedance
iv. else if the circuit is parallel:
1. Create a set of temporary variables for the result of the division
2. Iterate through the component values starting from the first component:
i. Divide 1+0j by the components impedance value and store the result appropriately, then add this result to the current sum.

3. Divide 1+0j by the total sum to give the total impedance.
v. Store the total impedance values in the appropriate place in the result table.

FUNCTION - PRINT_ RESULTS

1. Print the result table as shown below:
a. The first column describes the rows with the text
"COMPONENTS","Z ( Ohms)","I ( Amps)","V (Volts)".

b. The first row prints the components as ‘R' for resistor, ‘C' for capacitor and ‘I' for inductor.
c. The second row prints the impedance, the third the current and the fourth the voltage
i. The real part is printed in brackets in exponential format with sign and 3 decimal places. Then the ‘+' character. Then the imaginary part is printed in brackets in exponential format with sign and 3 decimal places. Then the ‘j' character.

CONSTRAINTS

- Pi needs to be to 11 decimal places in your program.
- Formatting needs to be exactly as specified. (Your program will be tested against automated test cases)
- Text to user needs to be easily understandable. You can change the text but the same inputs must be used.
- The program must print your student number, name and the assignment number as specified.
- Types should be used appropriately.
- You must use comments to explain significant lines of code.
- You must use comments to explain how to use the functions and solution

Attachment:- Assignment-2.pdf

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92281711
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in C/C++

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

  • 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