Question #39674

Write a C++ program to read each line of the input file, calculate the degrees in decimal for latitude and longitude and write the results to the output file.
1

Expert's answer

2014-03-31T12:06:56-0400

Answer on Question #39674- Programming, C++

1. Write a C++ program to read each line of the input file, calculate the degrees in decimal for latitude and longitude and write the results to the output file.

Solution.


#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
void outputf(double a);
int main()
{
    double a, b;
    cout << "\n Enter the number: ";
    cin >> a;
    b = pow(a, 2);
    cout << "\n >>=" << b;
    cout << "\n Enter the file name for the record number: \n";
    outputf(b);
    cout << endl;
    return 0;
}
void outputf(double a)
{
    ofstream f1;
    f1.open("D:\\filename.txt");
    if (!f1.fail())
    {
        f1 << a;
        f1.close();
    }
    else
    {
        cout << "\n Error opening file";
        return;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS