Define the Data types based upon Array of Possible for Artillery Programming.
#include
#include
#include
struct Projectile
{
char Pname[50];
double blastradius;
};
struct Artillery
{
char Aname[50];
double mVelocity;
double maxElevation;
double minElevation;
};
void PrintArtillery(struct Artillery artillery[])
{
strcpy(artillery[0].Aname, “Cannon”); artillery[0].mVelocity=200; artillery[0].minElevation= 0; artillery[0].maxElevation=45; //Populating the Artillery array
strcpy(artillery[1].Aname, “Howitzer”); artillery[1].mVelocity=900; artillery[1].minElevation= 20; artillery[1].maxElevation=65;
strcpy(artillery[2].Aname, “Mortar”); artillery[2].mVelocity=805; artillery[2].minElevation= 50; artillery[2].maxElevation=85;
//display menu for artillery
printf(“Artillery Namett Muzzle Velocityt Minimum Elevationt Maximum Elevation”);
int i;
for(i=0; i<3; i++)
printf(“n%d.%stt %1.fm/s tt %1.f degreestt %1.f degrees”,i+1,artillery[i].Aname,artillery[i].mVelocity,artillery[i].minElevation,artillery[i].maxElevation);
}
void PrintProjectile(struct Projectile projectile[])
{
strcpy(projectile[0].Pname,”High Explosive Anti -Tank”); projectile[0].blastradius= 5; //Populating the Projectile array
strcpy(projectile[1].Pname,”M549 HERA “); projectile[1].blastradius= 15;
strcpy(projectile[2].Pname,” W19 Katie AFAP”); projectile[2].blastradius= 4200;
//display menu for projectile
printf(“nnProjectile Namettt Blast Radius”);
int i;
for(i=0; i<3; i++)
printf(“n%d.%stt %1.f meters”,i+1,projectile[i].Pname, projectile[i].blastradius);
}
double CalculateAirTime(double velocity, double angle)
{
double t;
t = (2 * velocity * sin(angle)) / 9.8;
return t;
}
double CalculateRange(double velocity, double angle)
{
double max;
max = (velocity * velocity * sin(2 * angle)) / 9.8;
return max;
}
void SimulateProjectile(double * height, double * distance, double time, double velocity, double angle) // using pass by reference function
{
* height = velocity * time * sin(angle) – 0.5 * 9.8 * time * time; //formula to calculate height
* distance = velocity * time * cos(angle); // distance calculation
}
//main function
int main()
{
//local variables
int angleofelevation, muzzleVelocity, minelevation, maxelevation, flag = 0, choice_artillery = 0, choice_projectile=0, targetdistance;
double convert, angleRadians, distancetravelled, maxtime, airtime = 1;
double distance = 0;
double height = 0;
struct Artillery A[3];
struct Projectile P[3];
PrintArtillery(A);
do {
printf(“nEnter choice for Artillery (1 to 3): “);
//enter choice for artillery
scanf(“%d”, & choice_artillery);
if (choice_artillery == 1) {
angleofelevation = 45;
minelevation = 0, maxelevation = 45; //set minimum and maximum elevation
muzzleVelocity = 200; //set initial velocity
angleRadians = 3.14159 / 180 * angleofelevation; //converting angle of elevation from degree into radian
maxtime = CalculateAirTime(muzzleVelocity, angleRadians);
distancetravelled = CalculateRange(muzzleVelocity, angleRadians);
printf(“nnThe maximum range of the selected gun: %.2f N n”, distancetravelled); //giving the output (distance travelled) after calculation in screen
}
else if (choice_artillery == 2)
{
angleofelevation = 65;
minelevation = 20, maxelevation = 65; //set minimum and maximum elevation
muzzleVelocity = 900; //set initial velocity
angleRadians = 3.14159 / 180 * angleofelevation; //converting angle of elevation from degree into radian
maxtime = CalculateAirTime(muzzleVelocity, angleRadians);
distancetravelled = CalculateRange(muzzleVelocity, angleRadians);
printf(“nnThe maximum range of the selected gun: %.2f N n”, distancetravelled); //giving the output (distance travelled) after calculation in screen
}
else if (choice_artillery == 3)
{
angleofelevation = 85;
minelevation = 50, maxelevation = 85; //set minimum and maximum elevation
muzzleVelocity = 805; //set initial velocity
angleRadians = 3.14159 / 180 * angleofelevation; //converting angle of elevation from degree into radian
maxtime = CalculateAirTime(muzzleVelocity, angleRadians);
distancetravelled = CalculateRange(muzzleVelocity, angleRadians);
printf(“nnThe maximum range of the selected gun: %.2f N n”, distancetravelled); //giving the output (distance travelled) after calculation in screen
}
} while ((choice_artillery > 3) || (choice_artillery < 1));
PrintProjectile(P);
do{
printf(“nEnter choice for Projectile (1 to 3): “);
//enter choice for Projectile
scanf(“%d”, & choice_projectile);
}while(choice_projectile3);
//enter target distance
printf(“nEnter the value of target distance in meters: “);
scanf(“%d”, & targetdistance);
//loop to enter angle of elevation
do {
//enter angle of elevation
printf(“nEnter the value of angle of elevation in degrees: “);
scanf(“%d”, & angleofelevation);
//check condition
if (angleofelevation <= maxelevation && angleofelevation >= minelevation)
{
flag = 0;
}
else
{
printf(“nInvalid velocity!!! please enter valid angle of elevation”);
flag = 1;
}
}
while (flag == 1);
angleRadians = 3.14159 / 180 * angleofelevation; //converting angle of elevation from degree into radian
do {
SimulateProjectile( & height, & distance, airtime, muzzleVelocity, angleRadians);// calling
printf(“n At second %.2f , the shell is %.2f meters in the air and has travelled %.2f meters”, airtime, height, distance); //giving the output (distance travelled) after calculation in screen
airtime++;
}while (height > 0 );
airtime = (muzzleVelocity * sin (angleRadians)) / (0.5 * 9.8); // time when shell is in the ground
distance = muzzleVelocity * airtime * cos(angleRadians); // total distance travelled by the shell
printf(“n At second %.2f , the shell has hit the ground and has travelled %.2f meters”, airtime, distance);
printf(“n stimulation completen“);
printf(“n Total Air Time: %.2f N n”, airtime);
printf(“n Total Distance : %.2f N n”, distance);
if(P[choice_projectile-1].blastradius >= targetdistance) //check if target distance was less than or equal to the bladius radius or not
{
printf(“n Hitn “);
}
else
{
printf(“n Too long n”);
}
return 0;
}
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download