Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP WITH C# This is an overlapping squares problem. Basically, there are two squares on a positive plane. They may or may not be

NEED HELP WITH C#

This is an overlapping squares problem. Basically, there are two squares on a positive plane. They may or may not be overlapping, or one may even be inside the other. we have to use code to find the top right corner of each square, the projections of square1 and 2 on the x-axis, the size of the overlap of the x-axis projections, The projections of square 1 and 2 on the y-axis, and the size of the overlap of the y-axis projections.

I believe many if-statements and else-if statements must be used to complete this exercise.

"Your task in this lab is to practice simple manipulation of objects combined with prompting users for input, getting input in from the users, storing user input in variables, using if statements. This is a "code rewriting" -type exercise." You'll start with source code that we provide, and you make all necessary alterations.

Your main tasks are: Read, understand and execute the predefined solution, rewrite the content of the main part of the solutions to provide the correct answers in the code ensure your final solution will save, build and run successfully.

We were given this code to fill in/manipulate:

using System; namespace Lab_Exercise_4 { class Square // the definition of the Square class { private int CornerX; private int CornerY; private int Side; public Square(int valueX, int valueY, int valueS) // the constructor allowing initialisation { CornerX = valueX; CornerY = valueY; Side = valueS; } public int X // the three properties allowing access to the specs { get { return CornerX; } } public int Y { get { return CornerY; } } public int S { get { return Side; } } } // The main part of the program // Please make sure all values "unknown" are replaced by the correct numerical answers class Program { static void Main(string[] args) { Random rnd = new Random(); // initialisation of the random number generator string unknown = "unknown"; // declaration of "unknown" Square square1 = new Square(rnd.Next(100), rnd.Next(100), rnd.Next(100)); // creation of an object square1 Square square2 = new Square(rnd.Next(100), rnd.Next(100), rnd.Next(100)); // creation of an object square2 // Report the specificatons of both squares Console.WriteLine($"The bottom left corner of square 1 is: ({square1.X},{square1.Y}) and its side is: {square1.S}"); Console.WriteLine($"The bottom left corner of square 2 is: ({square2.X},{square2.Y}) and its side is: {square2.S}"); // Compute and report the top right corners of both squares Console.WriteLine($"The top right corner of square 1 is: ({unknown},{unknown})"); Console.WriteLine($"The top right corner of square 2 is: ({unknown},{unknown})"); // Projections on the X axis of both squares Console.WriteLine($"The projection of square 1 on X axis is: ({unknown},{unknown})"); Console.WriteLine($"The projection of square 2 on X axis is: ({unknown},{unknown})"); // Compute and report the size/length of the overlap of X axis projections Console.WriteLine($"The size of the overlap on X axis is: ({unknown})"); // Compute and report projections on the Y axis of both squares Console.WriteLine($"The projection of square 1 on Y axis is: ({unknown},{unknown})"); Console.WriteLine($"The projection of square 2 on Y axis is: ({unknown},{unknown})"); // Compute and report the size/length of the overlap of Y axis projections Console.WriteLine($"The size of the overlap on Y axis is: ({unknown})"); // Compute and report the size of the area of the overlap Console.WriteLine($"The size/area of the overlap is: ({unknown})"); } } }

//end of code

image text in transcribed

This is what part of the code will be like: if (XA Xa +Sa) Xoverlap=SB else (XA>Xe)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

1. Answer the question, What is human resource management?

Answered: 1 week ago