Respuesta :
Answer:
Pseudocode of the program:
Step 1: Start
Step 2: Declare variable x, y, velocity_X and velocity_y of float type to store value from user
Step 3: Ask user to provide value of x and y coordinate and velocity in x and y direction. Store in the respective variables
Step 4: While value of x and y is greater than 0 and less than 100, repeat step 5-7
Step 5: print the value of x and y
Step 6:If value of x is less than 0
The object exited from left
else If value of x is greater than 100
The object exited from right
If value of y is less than 0
The object exited from bottom
else If value of y is greater than 100
The object exited from top
Step 7: calculate new x and y coordinate as x= velocity_X and y= velocity_Y
Step 8: Stop
C-program
ConsoleApplication1
{
Video Animation
{
static void Main(string[] args)
{
// Take user inputs
Console.Write("Give the starting X position: ");
double X = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the starting Y position: ");
double Y = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the starting X velocity: ");
double velocity_X = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the starting Y velocity: ");
double velocity_Y = Convert.ToDouble(Console.ReadLine());
// Print starting values
Console.WriteLine("X:{0} Y:{1}", X, Y);
// Iterate loop till object goes out of screen
while (X>=0 && X<=100 )
{
// Increment values
// Print X and Y
X += velocity_X;
Y += velocity_Y;
Console.WriteLine("X:{0} Y:{1}", X, Y);
}
}
}
}