Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Orientations Design, edit, compile, and execute a C++ project. The application s

ID: 3769012 • Letter: O

Question

Orientations

Design, edit, compile, and execute a C++ project. The application should obtain values of two ac currents from the user. The user should be offered options to enter the currents’ values in either polar or rectangular coordinates. After the values have been entered, the user should chose to either add or subtract the two currents, or multiply a current by the value of a resistor. The result of each operation that is performed on ac currents should be displayed in polar coordinates.

The program should show a menu with the following inputs:

A selection of either polar or rectangular coordinates.

The values of two ac currents (the magnitude and phase shift if polar form is selected, or the real and imaginary parts if rectangular form is selected).

A selection of an operation (adding currents, subtracting currents, multiplying a current by a resistance, or exiting the program).

The output of the running of the project will show the results of the operation selected by the user (displayed in polar form).

Tips: ACurrent class should data members that represent the magnitude and phase, and the real and imaginary parts. You should use utility function members to set rectangular coordinates and polar coordinates, respectively.

Explanation / Answer

#include <iostream>
#include <math.h>
using namespace std;

class Current{
public:
   double magnitude, phase;
   double real, im;
   void setRect(double a, double b){
       real = a;
       im = b;
   }
   void setPolar(double a, double b){
       magnitude = a;
       phase = b;
   }
   // I have left the next 3 functions empty because I don't know electronics. Give the formulas and I'll modify them
   void add(Current c1, Current c2){
      
   }
   void subtract(Current c1, Current c2){
      
   }
   void mul(Current c1, double s){
      
   }
};

void input(Current *c){
   int x;
   cout << "Enter 1 for polar and 2 for rectangular: ";
   cin >> x;
   if(x == 1){
       cout << "Enter the polar coordinates: ";
       cin >> (*c).magnitude >> (*c).phase;
       (*c).setRect((*c).magnitude * cos((*c).phase), (*c).magnitude * sin((*c).phase));
   }
   else if(x == 2){
       cout << "Enter the rectangular coordinates: ";
       cin >> (*c).real >> (*c).im;
       (*c).setRect(sqrt((*c).real * (*c).real + (*c).im * (*c).im), atan((*c).im / (*c).real));
   }
}

int main(){
   Current c1, c2;
   cout << "Current 1 details: ";
   input(&c1);
   cout << "Current 2 details: ";
   input(&c2);
   while(true){
       int choice;
       cout << "1. Add currents 2.Subtract currents 3.Myltiply the current by a resistance 4. Exit";
       cout << "Enter your choice: ";
       cin >> choice;
       switch(choice){
       case 1:
           c1.add(c1, c2);
           break;
       case 2:
           c1.subtract(c1, c2);
           break;
       case 3:
           cout << "Enter the scalar value: ";
           double s;
           cin >> s;
           c1.mul(c1, s);
           break;
       case 4:
       return 0;
           break;
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote