❔ ✅ Trouble printing values

class Program
{
public static void Main()
{
var square = new Square(5);
Console.Write($"Side: {square.Side}");
Console.WriteLine($"Area: {square.Area()}");
Console.WriteLine($"Perimeter: {square.Perimeter()}");

var square2 = new Square(10);
Console.Write($"Side: {square2.Side}");
Console.WriteLine($"Area: {square2.Area()}");
Console.WriteLine($"Perimeter: {square2.Perimeter()}");
}
}

class Square
{
public int Side;

public Square(int side)
{ this.Side = side; }

public int Area() => this.Side * this.Side;
public int Perimeter() => this.Side * 4;
}
class Program
{
public static void Main()
{
var square = new Square(5);
Console.Write($"Side: {square.Side}");
Console.WriteLine($"Area: {square.Area()}");
Console.WriteLine($"Perimeter: {square.Perimeter()}");

var square2 = new Square(10);
Console.Write($"Side: {square2.Side}");
Console.WriteLine($"Area: {square2.Area()}");
Console.WriteLine($"Perimeter: {square2.Perimeter()}");
}
}

class Square
{
public int Side;

public Square(int side)
{ this.Side = side; }

public int Area() => this.Side * this.Side;
public int Perimeter() => this.Side * 4;
}
Expected output:
Side: 5
Area: 25
Perimeter: 20
Side: 10
Area: 100
Perimeter: 40
Side: 5
Area: 25
Perimeter: 20
Side: 10
Area: 100
Perimeter: 40
Actual output:
Side: 5Area: 25
Perimeter: 20
Side: 10Area: 100
Perimeter: 40
Side: 5Area: 25
Perimeter: 20
Side: 10Area: 100
Perimeter: 40
How do I get it to print under each other and not next to each other?
3 Replies
ero
ero2y ago
WriteLine instead of Write
mellowzippy
mellowzippyOP2y ago
Yup, found it Thank you lol !close
Accord
Accord2y ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server