Dec 14, 2016 at 6:11pm UTC
Hey guys i need some help i created this program on HP computer but i forgot to create a source file i moved my program to my mac and have no access to another windows computer. Can someone create a source file for me on windows. Thanks for any help. Here is the program i need a source file for.
include <iostream>
#include <fstream>
#include <string>
#include <Windows.h>
using namespace std;
void TAKE_OFF(double &mAH, ofstream &); // 100 mAH
void FLY_TO_NAV_POINT( double longitude, double latitude, int distance, double &mAH, ofstream & Drone_Finish ); // 10 mAH per meter of distance
void INCREASE_ELEVATION( int distance, double &mAH, ofstream & Drone_Finish ); // 30 mAH per meter of elevation distance
void DECREASE_ELEVATION( int distance, double &mAH, ofstream & Drone_Finish ); // 5 mAH per meter of elevation distance
void HOVER( int secs, double &mAH, ofstream & Drone_Finish ); // 8 mAH per second
void TAKE_PICTURES( double &mAH, ofstream & Drone_Finish, int seconds ); // 2 mAH per second-1
void LAND( double &mAH, ofstream & Drone_Finish ); // 20 mAH
int Drone_Menu( double &mAH, string &line );
int main(int argc, char* argv[])
{
string line;
double mAH=5200.0, longitude, latitude;
int distance;
bool Launch=false;
int Drone_Command, seconds;
if (argc < 3)
{ // We expect 3 arguments: the program name, the source path and the destination path
cerr << endl << endl << "Usage: Program_Name SOURCE_FILE.txt DESTINATION_FILE.txt"<< endl;
return 1;
}
string Flight = argv[1];
string Finish = argv[2];
ifstream Drone_Flight;
Drone_Flight.open(Flight);
if(!Drone_Flight.good())
{
cout << "Could not find the [" << Flight << "] Drone Flight Schedule.." << endl << endl;
cin >> line;// To keep screen open.
return 1;
}
ofstream Drone_Finish;
Drone_Finish.open(Finish);
cout << "\t********************************************************"<<endl;
cout << "\t\tLINAPPLESOFT USAF Drone Flight Plan Check" << endl;
cout << "\t********************************************************"<<endl;
Drone_Finish << "\t********************************************************\n";
Drone_Finish << "\t\tLINAPPLESOFT USAF Drone Flight Plan Check\n";
Drone_Finish << "\t********************************************************\n";
cout << endl << "Opening flight data from [" << Flight << "]";
cout << endl << endl << "--FLIGHT PLAN--";
Drone_Finish << "\nOpening flight data from [" << Flight << "]";
Drone_Finish << "\n\n--FLIGHT PLAN--";
do
{
getline(Drone_Flight,line);
Drone_Command = Drone_Menu( mAH, line);
if(Drone_Command != -1)
{
cout << endl << endl << "COMMAND : " << line;
Drone_Finish << "\n\nCOMMAND : " << line;
switch(Drone_Command)
{
case 0:
TAKE_OFF(mAH, Drone_Finish);
Launch = true;
break;
case 1:
if(Launch)
{
Drone_Flight >> longitude;
Drone_Flight >> latitude;
Drone_Flight >> distance;
FLY_TO_NAV_POINT( longitude, latitude, distance, mAH, Drone_Finish );
break;
}
else
{
cout << endl << "USAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE" << endl << endl;
Drone_Finish << "\nUSAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE\n";
return 1;
}
break;
case 2:
if(Launch)
{
Drone_Flight >> distance;
INCREASE_ELEVATION( distance, mAH, Drone_Finish );
break;
}
else
{
cout << endl << "USAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE" << endl << endl;
Drone_Finish << "\nUSAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE\n";
return 1;
}
break;
case 3:
if(Launch)
{
Drone_Flight >> distance;
DECREASE_ELEVATION( distance, mAH, Drone_Finish );
break;
}
else
{
cout << endl << "USAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE" << endl << endl;
Drone_Finish << "\nUSAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE\n";
return 1;
}
break;
case 4:
if(Launch)
{
Drone_Flight >> seconds;
HOVER( seconds, mAH, Drone_Finish );
break;
}
else
{
cout << endl << "USAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE" << endl << endl;
Drone_Finish << "\nUSAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE\n";
return 1;
}
break;
case 5:
if(Launch)
{
TAKE_PICTURES( mAH, Drone_Finish, seconds );
break;
}
else
{
cout << endl << "USAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE" << endl << endl;
Drone_Finish << "\nUSAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE\n";
return 1;
}
break;
case 6:
if(Launch)
{
LAND( mAH, Drone_Finish );
break;
}
else
{
cout << endl << "USAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE" << endl << endl;
Drone_Finish << "\nUSAF Drone was not sent a 'TAKE OFF' command. MISSION FORECAST: FAILURE\n";
return 1;
}
break;
}
}
}while(line!="X");
cout << endl << endl << "Total battery power required : " << 5200 - mAH << " mAH";
cout << endl << "Drone maximum battery capacity: 5200 mAH" << endl;
Drone_Finish << "\n\nTotal battery power required : " << 5200 - mAH << " mAH";
Drone_Finish << "\nDrone maximum battery capacity: 5200 mAH" << endl;
if(mAH >= 0)
{
cout << endl << "MISSION FORECAST: SUCCESS";
Drone_Finish << "\nMISSION FORECAST: SUCCESS";
}
else
{
cout << endl << "MISSION FORECAST: FAILURE";
Drone_Finish << "\nMISSION FORECAST: FAILURE";
}
cout << endl << endl << "Exporting flight data report to [" << Finish << "]";
Drone_Finish << "\n\nExporting flight data report to [" << Finish << "]";
cout << endl<<endl;
Drone_Flight.close();
Drone_Finish.close();
cin >> line;// To keep screen open.
}
void TAKE_OFF(double &mAH, ofstream & Drone_Finish)
{
cout << endl << "Energy consumed: 100 mAH";
Drone_Finish << "\nEnergy consumed: 100 mAH";
mAH-=100.0;
}
void FLY_TO_NAV_POINT( double longitude, double latitude, int distance, double &mAH, ofstream & Drone_Finish ) // 10 mAH per meter of distance
{
cout << endl << "Longitude: " << longitude;
cout << endl << "Latitude: " <<latitude;
cout << endl << "Distance: " << distance;
cout << endl << "Energy consumed: " << distance * 10 << " mAH";
Drone_Finish << "\nLongitude: " << longitude;
Drone_Finish << "\nLatitude: " << latitude;
Drone_Finish << "\nDistance: " << distance;
Drone_Finish << "\nEnergy consumed: " << distance * 10 << " mAH";
mAH-=distance * 10;
}
void INCREASE_ELEVATION( int distance, double &mAH, ofstream & Drone_Finish ) // 30 mAH per meter of elevation distance
{
cout << endl << "Elevation: " << distance;
cout << endl << "Energy consumed: " << distance * 30 << " mAH";
Drone_Finish << "\nElevation: " << distance;
Drone_Finish << "\nEnergy consumed: " << distance * 30 << " mAH";
mAH-=distance * 30;
}
void DECREASE_ELEVATION( int distance, double &mAH, ofstream & Drone_Finish ) // 5 mAH per meter of elevation distance
{
cout << endl << "Elevation: " << distance;
cout << endl << "Energy consumed: " << distance * 5 << " mAH";
Drone_Finish << "\nElevation: " << distance;
Drone_Finish << "\nEnergy consumed: " << distance * 5 << " mAH";
mAH-=distance * 5;
}
void HOVER( int secs, double &mAH, ofstream & Drone_Finish ) // 8 mAH per second
{
cout << endl << "Duration: " << secs << " secs";
cout << endl << "Energy consumed: " << 8*secs << " mAH";
Drone_Finish << "\nDuration: " << secs << " secs";
Drone_Finish << "\nEnergy consumed: " << 8*secs << " mAH";
mAH-=8*secs;
}
void TAKE_PICTURES( double &mAH, ofstream & Drone_Finish, int seconds ) // 2 mAH
{
cout << endl << "Energy consumed: " << 2* (seconds-1) << " mAH";
Drone_Finish << "\nEnergy consumed: " << 2* (seconds-1) << " mAH";
mAH -= 2* (seconds-1);
}
void LAND( double &mAH, ofstream & Drone_Finish ) // 20 mAH
{
cout << endl << "Energy consumed: 20 mAH";
Drone_Finish << "\nEnergy consumed: 20 mAH";
mAH-=20.0;
}
int Drone_Menu( double &mAH, string &line )
{
string Drone_Commands[7]={"TAKE OFF","FLY TO NAV POINT","INCREASE ELEVATION","DECREASE ELEVATION","HOVER","TAKE PICTURES","LAND"};
if(line != "X")
{
for(int command = 0;command<7;command++)
{
if(line == Drone_Commands[command])
return command;
}
}
return - 1;
}