It looks like you're new here. If you want to get involved, click one of these buttons!
/*
Following on from a previous shooting related program,
this program will work out if you have a specific powered
rifle would it hit the target... pretty important thing to
know really. Trial and Error based game, figure out the
closest you can get from an unknown target by guessing
what velocity and airtime you will need
*/
#include <iostream>
int main()
{
//variables
double vel, dist, time;
//intro
std::cout << \"Well yet another random/simple program by me, Semtex-Primed.\n\"
<< \"for this one you need to enter a Velocity followed by a time,\n\"
<< \"from this you have to get close to an unknown target.\n\n\";
//velocity
std::cout << \"Enter Velocity: \";
std::cin >> vel;
//time
std::cout << \"Enter Time: \";
std::cin >> time;
//calculation
dist = vel / time;
/*
1st if statement, if the calculated distance is less than 15, return the output.
Notice how when we state the conditions for if, we then begin a new 'code-block'
which is executed if the 'if' statement is true and then finishes when the code-block
brackets close. So the if only execute what you put within the '{ }' brackets.
*/
if(dist < 15)
{
std::cout << \"You've missed your target [fell short of the target]\";
}
/*
2nd if, same as 1st but above 15.
*/
if(dist > 15)
{
std::cout << \"You've missed your target [went too far]\";
}
/*
If the calculated distance is equal to 15, then you were correct.
*/
if(dist == 15)
{
std::cout << \"Direct hit!! Congratulations!\";
}
std::cout << \"\n\n\" << \"Distance covered [in metre's]: \" << dist;
return 0;
}
cool i hope me too make such a program like you.