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

Plz, use C++ code Use the file polar dat in Blackboard secion Code- Ch6-10- Chs

ID: 3858458 • Letter: P

Question



Plz, use C++ code

Use the file polar dat in Blackboard secion Code- Ch6-10- Chs for tis work The file polar.dat contains polar coordinates as distance and angle data pairs, one per line section Code. Ch6-10->Ch8 for this work Create a Ct+ program that reads this file and creates a second file named xycord dat. The entries in the new file should contain the rectangular coordinates cooresponding to the polar coordinates in the polar dat file. Polar coordinates are converted to rectanigular coordinates using these formulas r cos a r is the distance coordinate, a is the radadn equivalent of the angle coordinate Format the contents of xycord.dat so that numbers are properly aligned Submit the files polar dat xycord dat and the cpp file in a compressed file The cpp file should contain a comment at the top with your name, course code and date. ex Miguel Long MAC102 July 15, 2017 widhseuri ande d e d cntain a (20 points toward Quiz 4) Attach File Browse My Computer Browse Content Collection

Explanation / Answer

Input file: polar.dat

2.0 45.0

6.0 30.0

10.0 45.0

4.0 60.0

12.0 55.0

8.0 15.0

code:

#include <iostream>

#include <fstream>

#include <math.h>

using namespace std;

#define PI 3.14159265

int main()

{

ifstream inputfile("polar.dat");

ofstream outputfile("xycord.dat");

if(inputfile.is_open())

{

cout<<"input file opened succuessfully"<<endl;

while(!inputfile.eof())

{

float x,y,a,r;

inputfile>>r>>a;

cout << "Input : r -> :"<<r<<" "<<"a -> :"<<a<<endl;

x = r * cos (a*PI/180.0);

y = r * cos (a*PI/180.0);

cout << "OutPut: x -> :"<<x<<" "<<"y -> :"<<y<<endl;

outputfile<<x<<" "<<y<<endl;

}

inputfile.close();

}

else

cout<<"input file is not there in the folder"<<endl;

return 0;

}

output: xycord.dat

1.41421 1.41421

5.19615 5.19615

7.07107 7.07107

2 2

6.88292 6.88292

7.72741 7.72741

7.72741 7.72741

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