O programa deve oferecer suporte a seguinte funcionalidade:
r. permite que o usuário insira valores de 3 resistores em ohms.
b. permite que o usuário insira a tensão da bateria em V.
c. calcula e imprime a resistência equivalente do circuito e a corrente que flui através de cada resistor de configuração 1
(imagem mostra receptáculo de tensão na esquerda e 3 resistores em série em um circuito simples. Pessoalmente acho que sua desnecessária Ver a imagem).
d calcula e imprime a resistência equivalente do circuito e a corrente que flui através de cada resistor para configuração 2.
Mostra resister 1, 2 e 3 em paralelo um com o outro. Loop maior é mesclado com resister a linha 2, que está no meio de ligação entre os resistores 1 e 3. Tensão encontra-se à esquerda do loop maior.
Valores numéricos não estão presentes em imagens de usuário é para todos os valores de entrada.
Eu pareço ser preso no d e parte c. Qualquer ajuda seria apreciada por este trabalho de casa.
# incluem <iostream># incluem <string>usando o namespace std;
int main () {/ / explicar ao usuário a função de cout o programa < "simple="" circuits="" ";="" associate="" your="" variables="" with="" integers.="" int="" choice,="" done;="" utilize="" float="" to="" enable="" decimals="" for="" the="" program.="" float="" r1,="" r2,="" r3,="" v;="" double="" i,="" req;="" loop="" through="" the="" choices="" until="" the="" user="" decides="" to="" exit="" the="" program.="" done="0;" while(done="" !="1" )="" {="" cout=""> </> < endl;="" ask="" the="" user="" to="" start="" the="" program="" process="" dependent="" on="" which="" circuit="" to="" analyze.="" cout=""> </> < "are="" the="" resistors="" for="" this="" circuit="" in="" series="" or="" parallel?\n="" ";="" cout=""> </> < "if="" the="" resistors="" are="" in="" series="" please="" press="" 1:\n="" ";="" cout=""> </> < "if="" the="" resistors="" are="" in="" parallel="" please="" press="" 2:\n="" ";="" cout=""> </> < "if="" you="" wish="" to="" close="" the="" program="" please="" press="" 3:\n="" ";="" cout=""> </> < endl;="" cin=""> </>> escolha; cout < endl;="" sw="" switch="" (choice)="" {="" case="" 1:="" {="" ask="" the="" user="" for="" the="" resistor="" and="" voltage="" value(s).="" cout=""> </> < "please="" input="" the="" values="" for="" the="" resistors="" on="" the="" circuit="" in="" ohms.="" ";="" cout=""> </> < endl;="" cout=""> </> < "r1:="" ";="" cin=""> </>> R1; cout < "r2:="" ";="" cin=""> </>> R2;
cout < "r3:="" ";="" cin=""> </>> R3;
cout < endl;="" cout="">< "please="" enter="" the="" voltage="" of="" the="" battery="" source:="" ";="" cin="">> V;
/ / Escrever as equações a ser computada para resistores em série.
I = V / Req;
Req = R1 + R2 + R3;
/ / Executar os cálculos para fora atual colocar valores.
cout < endl;="" cout="">< "req=":" "="">< req="">< "="" ohms.\n";="" cout="">< "the="" current="" through="" resistor="" 1="" is:="" "="">< i="">< "="" amps.\n="" ";="" cout="">< "the="" current="" through="" resistor="" 2="" is:="" "="" &l="" cout="">< "the="" current="" through="" resistor="" 2="" is:="" "="">< i="">< "="" amps.\n="" ";="" cout="">< "the="" current="" through="" resistor="" 3="" is:="" "="">< i="">< "="" amps.\n="" ";="" cout="">< endl;="" break;="" }="" case="" 2:="" {="" ask="" the="" user="" for="" the="" resistor="" and="" voltage="" value(s).="" cout="">< "please="" input="" the="" values="" for="" the="" resistors="" on="" the="" circuit="" in="" ohms.="" ";="" cout="">< endl;="" cout="">< "r1:="" ";="" cin="">> R1;
cout < "r2:="" ";="" cin=""> </>> R2;
cout < "r3:="" ";="" cin=""> </>> R3;
cout < endl;="" cout="">< "please="" enter="" the="" voltage="" of="" the="" battery="" source:="" ";="" cin="">> V;
/ / Escrever as equações a ser computada para resistores em série.
I = ((V/R1)+(V/R2)+(V/R3));
Req = 1 /(1/R1)+(1/R2)+(1/R3);
/ / Executar os cálculos para fora atual colocar valores.
cout < cout="">< endl;="" cout="">< "equivalent="" resistance="" equals:="" "="">< req="">< "="" ohms.\n="" ";="" cout="">< "current="" through="" resistor="" 1:="" "="">< i="">< "="" amps.\n="" ";="" cout="">< "current="" through="" resistor="" 2:="" "="">< i="">< "="" amps.\n="" ";="" cout="">< "current="" through="" resistor="" 3:="" "="">< i="">< "="" amps.\n="" ";="" cout="">< endl;="" break;="" }="" case="" 3:="" {="" function="" that="" ends="" the="" program="" when="" the="" user="" presses="" 3.="" done="1;" break;="" }="" default:="" {="" cout="">< "that="" doesn't="" work...derp.\n="" ";="" cout="">< endl;
}
}
}
cin.get();
return 0;
}
Figured it out.
All I had to do is change the order of my equations in case 1 and the program ran successfully through and through!
endl;="" }="" }="" }="" cin.get();="" return="" 0;="" }="" figured="" it="" out.="" all="" i="" had="" to="" do="" is="" change="" the="" order="" of="" my="" equations="" in="" case="" 1="" and="" the="" program="" ran="" successfully="" through="" and="" through!=""></ endl;
}
}
}
cin.get();
return 0;
}
Figured it out.
All I had to do is change the order of my equations in case 1 and the program ran successfully through and through!
></></string></iostream>