Answer:
Find solutions for your homework
Find solutions for your homework
engineeringcomputer sciencecomputer science questions and answerstwo doubles are read as the voltage and the current of a wire object. declare and assign pointer mywire with a new wire object using the voltage and the current as arguments in that order. ex: if the input is 4.5 1.0, then the output is: wire's voltage: 4.5 wire's current: 1.0 #include <iostream> #include <iomanip> using namespace std; class wire
This problem has been solved!
You'll get a detailed solution from a subject matter expert that helps you learn core concepts.
See Answer
Question: Two Doubles Are Read As The Voltage And The Current Of A Wire Object. Declare And Assign Pointer MyWire With A New Wire Object Using The Voltage And The Current As Arguments In That Order. Ex: If The Input Is 4.5 1.0, Then The Output Is: Wire's Voltage: 4.5 Wire's Current: 1.0 #Include ≪Iostream≫ #Include ≪Iomanip≫ Using Namespace Std; Class Wire
Two doubles are read as the voltage and the current of a Wire object. Declare and assign pointer myWire with a new Wire object using the voltage and the current as arguments in that order.
Ex: If the input is 4.5 1.0, then the output is:
Wire's voltage: 4.5 Wire's current: 1.0
#include <iostream>
#include <iomanip>
using namespace std;
class Wire {
public:
Wire(double voltageValue, double currentValue);
void Print();
private:
double voltage;
double current;
};
Wire::Wire(double voltageValue, double currentValue) {
voltage = voltageValue;
current = currentValue;
}
void Wire::Print() {
cout << "Wire's voltage: " << fixed << setprecision(1) << voltage << endl;
cout << "Wire's current: " << fixed << setprecision(1) << current << endl;
}
int main() {
Wire* myWire = nullptr;
double voltageValue;
double currentValue;
cin >> voltageValue;
cin >> currentValue;
/* Your code goes here */
myWire->Print();
return 0;