Question

Write a C++ program that calculates the series and parallel resistance for a group of resister...

Write a C++ program that calculates the series and parallel resistance for a group of resister values. Your program will prompt for the number of resistors and then the values for those resistors. It will then calculate the equivalent series and parallel resistance values. For example, 3 resistors with the values of 100, 200 and 300 would yield the equivalent series resistance of 100+200+300.Your program should also continue to prompt for resistor values until 0 is entered. This program should contain at least 2 different types of loops. HINT: One loop is exact and the other until a change is entered.

Homework Answers

Answer #1

#include <iostream>
#include<iomanip>

using namespace std;

int main()
{
   int n[20],count,i=0,series=0;
   float parallel,temp =0;
   // User input for no.of resistors
   cout << "Enter the no.of resistors: ";
   cin >> count;
  
   cout << "Enter resistor values:\n";
   // loop for enter the resistor values
   while(count != 0)
   {
      cin >> n[i];
     
      if(n[i] == 0)
      break;
      count--;
      i++;
   }
   //loop to calculate series & parallel resistance
   for(int j =0;j<i;j++)
   {
       series = series + n[j];
       temp = temp + (1/ (float)n[j]);
   }
   parallel = 1/temp;
   // Displays the series & parallel resistance
   cout << "series resistance:" << series << "\n";
   cout << "parallel resistance:"<<fixed<< setprecision(6) <<parallel;
   
   return 0;
}

Know the answer?
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
Similar Questions
QUESTIONS FOR SERIES AND PARALLEL CIRCUITS 1. i) How does the equivalent resistance of a series...
QUESTIONS FOR SERIES AND PARALLEL CIRCUITS 1. i) How does the equivalent resistance of a series circuit compare to each individual resistor? ii) Answer the same question for a parallel circuit? 2. Assume that you have three 2Ω resistors. Show using a schematic drawing, how youwould connect these together to achieve the following resistances: (a) 1Ω, (b) 3Ω, and (c)4 Ω. Note that you do not always have to use all three resistors to achieve your goal. PAGE 2 3....
. A series-parallel combination of resistors is created from 4 resistors, there is a 45 ohm...
. A series-parallel combination of resistors is created from 4 resistors, there is a 45 ohm resistor followed in series by a parallel combination of a 30 Ohm resistor on one branch, and a 10 Ohm and a 15 Ohm resistors in series on the other branch. The whole combination is attached to a 12 V battery. a) find the net resistance of the resistors to the current from the battery. b) What is the current in the 45 Ohm...
Practice: Determine the total resistance of each of the following parallel circuits. Then use the Gizmo...
Practice: Determine the total resistance of each of the following parallel circuits. Then use the Gizmo to check your answer. (You can calculate the total resistance from the current and voltage using Ohm’s law, or use the Ohmmeter to measure the resistance directly.) A parallel circuit with a 20-ohm resistor and a 10-ohm resistor. A parallel circuit with two 20-ohm resistors and a 10-ohm resistor. A parallel circuit with a 15-ohm light bulb and a 20-ohm resistor. A parallel circuit...
1.) A 2.00 µF and a 7.50 µF capacitor can be connected in series or parallel,...
1.) A 2.00 µF and a 7.50 µF capacitor can be connected in series or parallel, as can a 50.0 kΩ and a 100 kΩ resistor. Calculate the four RC time constants (in s) possible from connecting the resulting capacitance and resistance in series. resistors and capacitors in series: __________s resistors in series, capacitors in parallel: ____________s resistors in parallel, capacitors in series:________________s capacitors and resistors in parallel: ____________________s 2) A 1.16 MΩ voltmeter is placed in parallel with a...
Please write it in c# program please and if possible no arrays only loops Loop Introduction...
Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into...
In C programming language please. -Construct a program that will make use of user defined functions,...
In C programming language please. -Construct a program that will make use of user defined functions, the do/while loop, the for loop and selection. -Using a do/while loop, your program will ask/prompt the user to enter in a positive value representing the number of values they wish to have processed by the program or a value to quit/exit. -If the user enters in a 0 or negative number the program should exit with a message to the user indicating they...
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16. d. Write a while which will display this set of values 16,13,10,7,4,1,-2. e. Write a for loop which will print ‘Loops are fun’ three times. f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number....
Develop a C++ program that determines the largest and second largest positive values in a collection...
Develop a C++ program that determines the largest and second largest positive values in a collection of data Prompt the user to enter integer values until they enter any negative value to quit You may presume the user will input at least two valid integer values Create a loop structure of some sort to execute this input cycle Maintain the largest and second largest integer as the user inputs data This logic should be placed inside your loop structure Arrays...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
C++ Goals:Practicing arrays Create a program that will read whole numbers from a file called Labs4-7Mu.dat...
C++ Goals:Practicing arrays Create a program that will read whole numbers from a file called Labs4-7Mu.dat (posted on Canvas)and store it into an array. The number of values in the file is less than 300 and all the values are whole numbers. The actual number of values stored in the file should be determined. Your program should then prompt the user to enter another whole number between 2 and 20 (you may assume the user enters a valid value) and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • 4. List and describe the THREE (3) necessary conditions for complete similarity between a model and...
    asked 17 minutes ago
  • In C++ Complete the template Integer Average program. // Calculate the average of several integers. #include...
    asked 22 minutes ago
  • A uniform rod is set up so that it can rotate about a perpendicular axis at...
    asked 24 minutes ago
  • To the TwoDArray, add a method called transpose() that generates the transpose of a 2D array...
    asked 45 minutes ago
  • How could your result from GC (retention time, percent area, etc.) be affected by these following...
    asked 55 minutes ago
  • QUESTION 17 What are the tasks in Logical Network Design phase? (Select five. ) Design a...
    asked 57 minutes ago
  • What is the temperature of N2 gas if the average speed (actually the root-mean-square speed) of...
    asked 1 hour ago
  • Question One: Basic security concepts and terminology                         (2 marks) Computer security is the protection of...
    asked 1 hour ago
  • In program P83.cpp, make the above changes, save the program as ex83.cpp, compile and run the...
    asked 1 hour ago
  • the determination of aspirin in commercial preparations experment explain why the FeCl3-KCl-HCl solution was ased as...
    asked 1 hour ago
  • Describe important events and influences in the life of Wolfgang Amadeus Mozart. What styles, genres, and...
    asked 1 hour ago
  • 3.12 Grade Statistics Write a python module "school.py" that prints school information (first 3 lines of...
    asked 1 hour ago