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
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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.