Question: Program Write a C program that implements a mini electrical circuit. The program presents a menu of options and prompts the user to choose one

Program

Write a C program that implements a mini electrical circuit. The program presents a menu of options and prompts the user to choose one of the options.

Function Prototypes

Write the function prototypes at the beginning of the program.

Write function definitions (the code) after main() function.

Required functions:

IMPORTANT: Precede each function with 4 lines of comments to document the function name, input parameters, output and task.

1)computeSeriesResistance( )

Input Parameters: 3 real numbers

Output: float

Task: Compute the resistance of a serial circuit with 3 resistors and return it as functions output. The formula is:

Serial Resistance = R1 + R2 + R3

Assume R1, R2, R3 are the resistance values of three resistors:

2)computeParallelResistance( )

a.Input Parameters: 3 real numbers

b.Output: float

c. Task: Compute and return the resistance of a parallel circuit with 3 resistors and return it as output.

3)computeVoltage ( )

The Ohms formula for calculating voltage across the resistor is: V = IR. Where V is the voltage; I is the current and R is the resistance.

a.Input Parameters: current as a whole number; resistance as a real number.

b.Output: float

c.Task: Compute the voltage using Ohms formula: V = IR

4)display_myInfo()

a.Input Parameters: none

b.Output: void

c.Task: Display programmers info in a box of stars

5)display_menu()

a.Input Parameters: none

b.Output: void

c.Task: Display the menu of options. The menu is as follows:

Mini Electrical Circuit

====================

1)Equivalent series resistance

2)Equivalent parallel resistance

3)Ohms Law

4)Exit

// main should be the first function in your program

main()

{

-Declare variables as needed.

-Invoke the function to display your info in a box of stars.

-Prompt the user to enter 3 resistor values, read them into three float variables, r1, r2, r3.

-Prompt the user to enter the resistor value, R and the current I in a circuit.

-Invoke the function to display the menu of options.

Prompt the user to choose an option. Read it into an int variable.

-Use a switch statement to process the selected option

Option- 1

Invoke computeSeriesResistance() passing r1, r2, r3 as input arguments.

Display the total resistance in main( ).

Option-2

Invoke computeParallelResistance() passing r1, r2, r3 as input arguments.

Display the output in main().

Option-3

Invoke computeVoltage () to compute the voltage, passing R and I as input arguments.

Display the voltage in main().

Option-4

Display Program will end now.

Default:

Display: Invalid Option, try again.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!