Answer to Question #139613 in C++ for Danish Hussain

Question #139613
Write a c++ program that accepts values of two linear resistors as input from user and asks the user he want to solve in series or parallel if he answer parallel calculate the values in parallel
1
Expert's answer
2020-10-22T11:10:39-0400
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int R1, R2, Rtot;
    string connect;
    cout << "Please enter values R1 and R2: ";
    cin >> R1 >> R2;
    if(R1==0 or R2==0){
    cout << "There is no such resistor!";
    }
    else{
    cout << "Do you want to solve it in series or parallel? Please enter 'series' or 'parallel' \n";
    cin >> connect;
    if (connect=="parallel") {
        cout << "The total resistance is "<< (float) R1*R2/(R1+R2);
    };    
    };
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS