Blackreach10
New member
- Joined
- Jan 10, 2021
- Messages
- 2
- Programming Experience
- Beginner
Hi I am a complete beginner doing an intro to C# course. I keep getting 'Unexpected symbol' error for the code below, no matter what I put in. Can anyone advise? Many thanks!
C#:
/// <summary>
/// Programming Assignment 1
/// </summary>
class Program
{
// x and y coordinates for points
static float point1X;
static float point1Y;
static float point2X;
static float point2Y;
/// <summary>
/// Calculates angle and distance between two points
/// </summary>
/// <param name="args">command-line args</param>
static void Main(string[] args)
{
// loop while there's more input
string input = Console.ReadLine();
while (input[0] != 'q')
{
// extract point coordinates from string
GetInputValuesFromString(input);
// Add your code between this comment
// and the comment below. You can of
// course add more space between the
// comments as needed
float X1=2, Y1=2, X2=1, Y2=1
//calculate the delta x and delta y between the two points
float deltaX = Math.Pow((X2 - X1) ;
float deltaY = Math.Pow((Y2 - Y1) ,
//pythagoras theorem for distance
var = Math.Sqrt(deltaY + deltaX),
//atan2 for angle
float radians = Math.Atan2((Y2 - Y1), (X2 - X1));
//radians into degrees
var angle = radians * (180 / Math.PI);
WriteLine(Dist = + distance);
WriteLine(angle = + angle);
Last edited by a moderator: