UAEU EE Computer Programming ELEC330 FALL 20162017 Group Pro

UAEU EE Computer Programming ELEC330, FALL 2016/2017 Group Project Due to 7th, Dec 2016 11:00 a.m. The submission should be to the Blackboard ONLY. Group will be created for this purpose You can work with groups of maximum 4 students. A (10-15 min) discussion will be carried out with every group, with-in the last week of work. You have to keep all documents in use, since it will be necessary for discussion, for example, drafts, pseudo-codes, and etc. The names, student IDs, and section number must appear as comments. Problem Earth is the third nearest the fifth largest of the nine planets that orbit the sun. The planets provide a lot of interesting numbers for measurement and computation. The following table includes some information about each planet which will be used during your task Time of revolution Distance from Approximate Weight Planet Sun in km diameter in km. multiplier factor around the Sun. 5.8 x 107 Mercury 4, 840 0.38 88 days 12, 200 1.03 x 10 Venus 0.91 224.7 days 1.55 x 108 12, 756 1.00 365.25 days Earth Mars 2.28 x 10 6, 787 0.38 687 days 2.60 7.78 x 108 142, 200 11.86 years Jupiter 1.427 x 109 120, 600 1.10 29.46 years Saturn 7 Uranus 2.87x108 0.90 51, 300 84.01 years 4.497 x 109 Neptune 49, 1000 1.20 164.8 years 5.9 x 109 Pluto 2, 3000 0.08 248.5 years The main purpose of your supposed program is to examine computation power ofthese numbers, specifically the distance between two planets, the weight and age if you were to travel to different planets, the time required to go around a specific planet, and the time required to send a message from one planet to another. The program must have the following features Print planet info function, to print all information in the above table. 2. Print options function, to print the options your program is capable achieve. 3. Get option function, to read and return the desired option. 4. Cal age function to calculate and return the age if you are living on another planet 5. Cal weight function to calculate and return the weight if you are living on another planet. 6. Cal message function to calculate and return the time required to send message from one planet to another 7. Cal distance function to calculate and return the distance between any two planets 8. Cal time function to calculate and return the time required going around a certain planet. 9. Any conditional loop to keep the program running until the user chooses the close (END)option.

Solution

#include<stdio.h>
void print_planet_info();
void print_options();
int get_option();
float cal_age();
float cal_weight();
float cal_message();
float cal_distance();
float cal_time();
char p1[]=\"Mercury\";
char p2[]=\"Venus\";
char p3[]=\"Earth\";
char p4[]=\"Mars\";
char p5[]=\"Jupiter\";
char p6[]=\"Saturn\";
char p7[]=\"Uraus\";
char p8[]=\"Nuptune\";
char p9[]=\"Pluto\";
int dis[]={58,103,155,288,778,1427,2870,4497,5900};

int diam[]={4840,12200,12756,6787,142200,120600,51300,49100,2300};
float factor[]={0.38,0.91,1.00,0.38,2.60,1.10,0.90,1.20,0.08};
float time[]={88,224.7,365.25,687,4328.9,10752.9,30663.65,60152,90702.5};
int main()
{
   int ch;  
   float out;
   print_planet_info();
   print_options();
   do{
  
   ch=get_option();
   switch(ch)
   {
       case 1:
           printf(\"Answer is %f\ \",cal_age());
           break;
       case 2:
           printf(\"Answer is %f\ \",cal_weight());
           break;
       case 3:
           printf(\"Time required %f (sec)\ \",cal_message());
           break;
       case 4:
           printf(\"Distance : %f x 10^6\ \",cal_distance());
           break;
       case 5:
           printf(\"Time is: %f\",cal_time());
           break;
  
   }
   }while(ch!=6);
  
}
void print_planet_info()
{
   int i=1;
   printf(\"#\\tPlanet\\tDistance form sum(km)\\tDiameeter(km)\\tWeight multiplier factor\\tTime of revolution around the sun\ \");
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p1,dis[0],diam[0],factor[0],time[0]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p2,dis[1],diam[1],factor[1],time[1]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p3,dis[2],diam[2],factor[2],time[2]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p4,dis[3],diam[3],factor[3],time[3]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p5,dis[4],diam[4],factor[4],time[4]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p6,dis[5],diam[5],factor[5],time[5]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p7,dis[6],diam[6],factor[6],time[6]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p8,dis[7],diam[7],factor[7],time[7]);
   printf(\"%d\\t%s\\t%d x 10^6\\t\\t%d\\t\\t%f\\t\\t\\t%f\ \",i++,p9,dis[8],diam[8],factor[8],time[8]);
  
}
void print_options()
{
   printf(\"1.cal_age\ 2.cal_weight\ 3.cal_message\ 4.cal_distance\ 5.cal_time\ 6.Exit\ \");
}
int get_option()
{
   int op;
   scanf(\"%d\",&op);
   return op;
}
float cal_age()
{
   float age ;
   int i;
   printf(\"Enter age: \");
   scanf(\"%f\",&age);
   printf(\"Enter planet #: \");
   scanf(\"%d\",&i);
   return (age*365.25)/(time[i-1]);
}
float cal_weight()
{
   float wei ;
   int i;
   printf(\"Enter weight: \");
   scanf(\"%f\",&wei);
   printf(\"Enter planet #: \");
   scanf(\"%d\",&i);
   return factor[i-1]*wei;
}
float cal_message()
{
   int i,j;
   float f;
   printf(\"enter the two planet #: \");
   scanf(\"%d%d\",i,j);
   f=dis[j-1]-dis[i-1];
   return f/.3;
}
float cal_distance()
{
   int i,j;
   printf(\"enter the two planet #: \");
   scanf(\"%d%d\",i,j);
   return dis[j-1]-dis[i-1];
}
float cal_time()
{
   int i,speed;
   printf(\"Enter planet #: \");
   scanf(\"%d\",&i);
   printf(\"Enter speed: \");
   scanf(\"%d\",&speed);
   return ((22/7)*diam[i-1])/speed;

  
}

 UAEU EE Computer Programming ELEC330, FALL 2016/2017 Group Project Due to 7th, Dec 2016 11:00 a.m. The submission should be to the Blackboard ONLY. Group will
 UAEU EE Computer Programming ELEC330, FALL 2016/2017 Group Project Due to 7th, Dec 2016 11:00 a.m. The submission should be to the Blackboard ONLY. Group will
 UAEU EE Computer Programming ELEC330, FALL 2016/2017 Group Project Due to 7th, Dec 2016 11:00 a.m. The submission should be to the Blackboard ONLY. Group will

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site