(TCO 3) Write a complete C++ console mode program (#includes, etc., but no prolo
ID: 3629085 • Letter: #
Question
(TCO 3) Write a complete C++ console mode program (#includes, etc., but no prologue) that solves a simple DC circuit problem. Given a DC voltage source of some magnitude, find the voltage drops across the 2 resistors. The user will provide the values for the voltage source and the 2 resistor values. The formula that you will need is:
VRx = Vsupply * Rx / (Rx + Ry) // Voltage Divider rule
· Use appropriate data types.
· Valid input is any positive real number. If the user input is zero or negative, your program should print an error message and not try to compute any results.
· Be sure to display explanatory text to make the input and output clear to the user. Results should be output with 3 digits following the decimal point.
(Points : 15)
5. (TCO 4) Create a C++ program that uses a while-loop to display the odd numbers between 15 and 30 including 15. The numbers should be displayed one per line. (Points : 15)
Explanation / Answer
please rate - thanks
next time 1 question per post
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{double VRx,Vsupply,Rx,Ry;
cout<<"Enter DC magnitude: ";
cin>>Vsupply;
if(Vsupply<=0)
cout<<"must be >0 program aborting ";
else
{cout<<"Enter value for resistor 1: ";
cin>>Rx;
cout<<"Enter value for resistor 2: ";
cin>>Ry;
VRx=Vsupply*Rx/(Rx+Ry);
cout<<"The voltage drops = "<<setprecision(3)<<fixed<<VRx<<endl;
}
system("pause");
return 0;
}
------------------------
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{int n=15;
cout<<"Odd numbers betwee, 15 and 30 ";
while(n<=30)
{cout<<n<<endl;
n+=2;
}
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.