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

/******************************************************************/ /* Program

ID: 3805265 • Letter: #

Question

/******************************************************************/
/* Program chapter4_5                                             */
/*                                                                */
/* This program computes and prints the pseudorange for           */
/* 4 satellites. It also prints the number of the satellite      */
/* that is closest to the receiver.                               */

#include<iostream> //Required for cout
#include<cfloat>   //required for DBL_MAX
using namespace std;

int main()
{
//Declare and initialize objects
const double C(299792458.0); //meters per second
const int NUMBER_OF_SATELLITES(5);
int satID, minID,maxID;
double tTime, pRange, minPRange(DBL_MAX), maxPRange(0);

//Prompt user for input
cout << "Enter id and transit time for "
  << NUMBER_OF_SATELLITES << " satellites: "
  << "Use whitespace to separate the values(ie: 25 0.00567) "
  << endl;

for (int i = 1; i <= NUMBER_OF_SATELLITES; ++i)
{
  cin >> satID >> tTime;
  pRange = tTime*C;

  //Check for closest satellite
  if (pRange < minPRange)
  {
   minPRange = pRange;
   minID = satID;
  }
  if (pRange > maxPRange)
  {
   maxPRange = pRange;
   maxID = satID;
  }
  cout << "Satellite " << satID << " has a pseudorange of "
   << pRange << " m " << endl;
}
//Output ID of closest satellite
cout << " Satellite " << minID
  << " is closest to GPS receiver with range =" <<minPRange<< endl;
//Output ID of farthest satellite
cout << " Satellite " << maxID
  << " is farthest from GPS receiver with range =" <<maxPRange<< endl;
system("pause");
return 0;
}

HAND IN LABORATORY TASK: LAB #17 The program is a modification of the previous satellite program. Use that code as the basis to do the following Modify it to find the Satellite that is farthest and closest from the GPS receiver using the data Below. And also modify it for 6 satellite data as input. See below Program will output the satellite number and pseudo range of each and the And the final output is the farthest and closest satellite from the GPS receiver Outputting The satellite numbers and pseudo range calculated it found is produced Remember to use descriptive variable names and comments to you and the user Satellite data to use Satellite number measured Transit times 3098 00234 00101 1243 00099 00567 9876 2018 00901 00777

Explanation / Answer

/******************************************************************/
/* Program chapter4_5 */
/* */
/* This program computes and prints the pseudorange for */
/* 4 satellites. It also prints the number of the satellite */
/* that is closest to the receiver. */
#include<iostream> //Required for cout
#include<cfloat> //required for DBL_MAX
using namespace std;
//Main function definition
int main()
{
//Declare and initialize objects
const double C(299792458.0); //meters per second
const int NUMBER_OF_SATELLITES(6);
int satID, minID,maxID;
double tTime, pRange, minPRange(DBL_MAX), maxPRange(0);
//Prompt user for input
cout << "Enter id and transit time for "<< NUMBER_OF_SATELLITES << " satellites: "
<< "Use whitespace to separate the values(i.e.,: 25 0.00567) "
<< endl;
for (int i = 1; i <= NUMBER_OF_SATELLITES; ++i)
{
cin >> satID >> tTime;
pRange = tTime*C;
//Check for closest satellite
if (pRange < minPRange)
{
//Updates the minimum P Range to current pRange
minPRange = pRange;
//Updates minimum Id to current satellite id
minID = satID;
}//End of if condition
//Checks for the farthest satellite
if (pRange > maxPRange)
{
//Updates the maximum P Range to current pRange
maxPRange = pRange;
//Updates maximum Id to current satellite id
maxID = satID;
}//End of if condition
cout << "Satellite " << satID << " has a pseudorange of "
<< pRange << " m " << endl;
}
//Output ID of closest satellite
cout << " Satellite " << minID
<< " is closest to GPS receiver with range =" <<minPRange<< endl;
//Output ID of farthest satellite
cout << " Satellite " << maxID
<< " is farthest from GPS receiver with range =" <<maxPRange<< endl;

return 0;
}//End of main

Output:

Enter id and transit time for 6 satellites:
Use whitespace to separate the values(i.e.,: 25 0.00567)

3098 .00234 1243 .00101 1111 .00099 9876 .00567 2018 .00901 7777 .00777
Satellite Number3098 Measured Transit times701514 m

Satellite Number1243 Measured Transit times302790 m

Satellite Number1111 Measured Transit times296795 m

Satellite Number9876 Measured Transit times1.69982e+006 m

Satellite Number2018 Measured Transit times2.70113e+006 m

Satellite Number7777 Measured Transit times2.32939e+006 m


Satellite 1111 is closest to GPS receiver with range =296795

Satellite 2018 is farthest from GPS receiver with range =2.70113e+006