Question

Please, I need help, I cannot figure out how to scan variables in to the function prototypes!Input Pararmeters: 3 real numbers Output: float Task: Compute the resistance of a serial cicuit with 3 resistors and return it as main should be the first function in your program maini 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, r functions output. The formula is Serial Resistance = R1 + R2 R3 Assume R1, R2. R are the resistance values of three resistors: r2. 13 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. a. Input Parameters: 3 real numbers b. Output: float c. Task: Compute and return the resistance of a parallel circuit with 3 resistors o Prompt the user to choose an option. Read it into an variable. Use a switc statement to process the selected option *Invoke somnuSsricaRcaistans0 passing rl, r2, r3 as input Display the total resistance in main). *Invoke samauteParallcRcsistan0 passing rl, r2, r3 as input Display the output in mainO. · Invoke computeVoltage 0 to compute the voltage, passng R and Display the voltage in main. o Option-1 and return it as output. The formula is: Resistance-T R1 R2 R3 o Option-2 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. o Option-3 a. b. c. Input Parameters: current as a whole number; resistance as a real number Output: float Task: Compute the voltage using Ohms formula: V-IR 1nput arguments. o Option-4 Display Program will end now. o Default: a. Input Parameters: none b. Output: void c. Task: Display Display: Invalid Option, try again. programmers info in a box of stars in Grading chart: Function Prototypes(0.5 a. b. c. Input Parameters: none Output: void Task: Display the menu of options. The menu is as follows: Mini Electrical Circuit Intro comments (-1 if missing) display mem Function 1) Equivalent series resistance 2) Equivalent parallel resistance 3) Ohms Law 4) Exit

******This is what the program should look like as it runs but I cannot figure out how to successfully build the code to do such.******

My code:

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <math.h>

#include <conio.h>

float computeSeriesResistance(float R1, float R2, float R3);

float computeParallelResistance(float R1, float R2, float R3);

float computeVoltage(int current, float resistance);

void getInputR(float R1, float R2, float R3);

void getInputCandR(int current, float resistance);

void myInfo();

void displayMenu();

int main()

{

myInfo();

getInputR();

getInputCandR();

displayMenu();

float R1, R2, R3;

float resistance;

int current;

int choice; //get the choice of the user

scanf("%d", &choice);

while (choice != 4) //exit when user gives 4

{

if (choice == 1)

printf("After Computing Series resistance : %f\n", computeSeriesResistance(R1, R2, R3));

if (choice == 2)

printf("After Computing Parallel resistance : %f\n", computeParallelResistance(R1, R2, R3));

if (choice == 3)

printf("After Computing Volatege : %f\n", computeVoltage(current, resistance));

displayMenu();

scanf("%d", &choice);

}

getchar();

return 0;

}

void getInputR(float R1, float R2, float R3)

{

printf("Enter three resistor values: ");

scanf("%f%f%f", &R1, &R2, &R3);

}

void getInputCandR(int current, float resistance)

{

printf("\n\nEnter a current (whole #) and the resisistance (real #): ");

scanf("%d%f", &current, &resistance);

}

float computeSeriesResistance(float R1, float R2, float R3)

{

return R1 + R2 + R3;

}

float computeParallelResistance(float R1, float R2, float R3)

{

float f = (1.0 / R1) + (1.0 / R2) + (1.0 / R3);

printf("%f\n", f);

return 1 / f;

}

float computeVoltage(int current, float resistance)

{

return current*resistance;

}

void myInfo()

{

printf("************************************\n");

printf("*\t\t\t *\n");

printf("*\\t *\n");

printf("*\t\t\t\t *\n");

printf("*\t\t\t *\n");

printf("************************************\n");

}

void displayMenu()

{

printf("Mini Electrical Circuit\n");

printf("--------------------------\n");

printf("--------------------------\n");

printf("1.Equivalant Series Resitance\n");

printf("2.Equivalant Parallel Resitance\n");

printf("3.Ohm's law: V = I * R\n");

printf("4.Exit\n");

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Made changes to your code. so once check and run.

**CODE:

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <math.h>

#include <conio.h>

float computeSeriesResistance(float R1, float R2, float R3);

float computeParallelResistance(float R1, float R2, float R3);

float computeVoltage(int current, float resistance);

void getInputR();

void getInputCandR();

void myInfo();

void displayMenu();

float R1, R2, R3;

float resistance;

int current;

int main()

{

myInfo();

getInputR();

getInputCandR();

displayMenu();

int choice; //get the choice of the user
printf("\nEnter your choice : ");

scanf("%d", &choice);

while (choice != 4) //exit when user gives 4

{

if (choice == 1)

printf("After Computing Series resistance : %.2f\n\n", computeSeriesResistance(R1, R2, R3));

if (choice == 2)

printf("After Computing Parallel resistance : %.2f\n\n", computeParallelResistance(R1, R2, R3));

if (choice == 3)

printf("After Computing Volatege : %.2f\n\n", computeVoltage(current, resistance));

displayMenu();
printf("\nEnter your choice : ");

scanf("%d", &choice);

}

getchar();

return 0;

}

void getInputR()

{

printf("Enter three resistor values: ");

scanf("%f %f %f", &R1, &R2, &R3);

}

void getInputCandR()

{

printf("Enter a current (whole #) and the resisistance (real #): ");

scanf("%d %f", &current, &resistance);

}

float computeSeriesResistance(float R1, float R2, float R3)

{

return R1 + R2 + R3;

}

float computeParallelResistance(float R1, float R2, float R3)

{

float f = (1.0 / R1) + (1.0 / R2) + (1.0 / R3);

return 1 / f;

}

float computeVoltage(int current, float resistance)

{

return current*resistance;

}

void myInfo()

{

printf("************************************\n");

printf("*\t\t\t *\n");

printf("*\\t *\n");

printf("*\t\t\t\t *\n");

printf("*\t\t\t *\n");

printf("************************************\n");

}

void displayMenu()

{

printf("\nMini Electrical Circuit\n");

printf("--------------------------\n");

printf("--------------------------\n");

printf("1.Equivalant Series Resitance\n");

printf("2.Equivalant Parallel Resitance\n");

printf("3.Ohm's law: V = I * R\n");

printf("4.Exit\n");

}

CAUsersiLENOVONDownloadsApayibin\Debugipay.exe 치t * Enter three resistor values: 5.25 7 6.5 Enter a current (whole #) and the

**Comment for any further queries.

Add a comment
Know the answer?
Add Answer to:
Please, I need help, I cannot figure out how to scan variables in to the function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ HELP I need help with this program. I have done and compiled this program in...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...

  • C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...

  • Complete the functions for the program complex.c (Down) . The program adds, subtracts,and multiplies complex numbers....

    Complete the functions for the program complex.c (Down) . The program adds, subtracts,and multiplies complex numbers. The C program will prompt the user for the choice of operations,read in the complex numbers, perform the operations, and print the results. The main programrepeatedly prints the menu, reads in the user’s selection, and performs the operation. We use pointers only for those arguments that the function intends to change. In all thefunctions, r represents the real component and i represents the imaginary...

  • So I have a question in regards to my program. I'm learning to program in C...

    So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...

  • C programming - This is what I have so far but it is not working correctly....

    C programming - This is what I have so far but it is not working correctly. It must contain the function and it also needs a provision to write output to a file. Can anyone help? #include <stdio.h> I #include <math.h int main (void) int V float Rint, RLE0, 0; printf New power supply voltage scanf ("td", &V) printf Enter a valid Internal Resistance (Rint) range between 200 and 5k ohms: scanf ("tf", Rint if (V> 1 && VK 15)...

  • Need help with this C program? I cannot get it to compile. I have to use...

    Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...

  • I need little help with C language. I need to pass what I get from HexToBin(char*...

    I need little help with C language. I need to pass what I get from HexToBin(char* hexdec) into char* input so that what I got there it should pass it as string array parametr. Example: Enter IEEE-Hex: 40200000 Equivalent Binary value is : 01000000001000000000000000000000 Decimal Number: 2.5 #include <stdio.h> void HexToBin(char* hexdec) {    long int i = 0;    while (hexdec[i]) {        switch (hexdec[i]) {        case '0':            printf("0000");            break;...

  • C linux please write it by only using “if and else” conditions, thanks so much this...

    C linux please write it by only using “if and else” conditions, thanks so much this is my task 3 Requirements 1. Copy your solution for Task 3 t3.c to a new file t4.c. 2. The input is guaranteed to contain at least one non-whitespace character. 3. If the input is well-formed, i.e., can be parsed to a number, the program should behave identically to Task 3. All the requirements of Task 3 still apply except the file name. 4....

  • I am trying to change my code so i no longer need the function that reads...

    I am trying to change my code so i no longer need the function that reads in the users base and height input but rather uses the implementation of argument vector in C. I want to accept command line arguments and have it calculate my area. so i want to type this into the command line and have it calculate my area project1 5 4 #include <stdio.h> void userDimensions(float *base, float *height) { scanf("%f", base); scanf("%f", height); } float calcArea(float...

  • NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A...

    NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION.   Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT