Architect Arithmetic incorrect result?

Hi,

At the point 10 (Architect Arithmetic challenge) why is the cost 748510782.02 pesos?
I got different result but I can’t figure out why?
My result is: 718637251.82 peso

Here is my code:
using System;

namespace ArchitectArithmetic
{
  class Program
  {
    public static void Main(string[] args)
    {
      // for test:
      /*
      Console.WriteLine(RectangularArea(5, 4));
      Console.WriteLine(CircleArea(4));
      Console.WriteLine(TriangleArea(10, 9));
      */
      double rect = RectangularArea(1500, 2500);
      double halfCircle = CircleArea(375 / 2) / 2;
      double triangle = TriangleArea(750, 500);

      double areaOfTeotihuacan = rect + halfCircle + triangle;

      double flooringCost = areaOfTeotihuacan * 180; // in Mexican peso

      Console.WriteLine($"The area of Teotihuacan is: {areaOfTeotihuacan} square metre.");
      Console.WriteLine($"The flooring-cost is: {Math.Round(flooringCost, 2)} Mexican peso.");
      Console.WriteLine($"The flooring-cost is: {CalculateTotalCost(areaOfTeotihuacan, 180)} Mexican peso.");
    }

    static double RectangularArea(double length, double width) {
      return length * width;
    }

    static double CircleArea(double radius) {
      return Math.PI * Math.Pow(radius, 2);
    }

    static double TriangleArea(double bottom, double height) {
      return 0.5 * bottom * height;
    }

    static double CalculateTotalCost(double area, double price) {
      return Math.Round(area * price, 2);
    }
  }
}

1 Like

Try to adding writeLine statements at every point you make a calculation to make sure it’s what you want. Remember that division and rounding can have strange effects.

Hi,
A bit later I found why is my result is different.
The author computed the circle area with radius = 375, but I computed with 375 / 2.
On the sketch 375 is the diameter.
Maybe anyone have to correct the solution at point 10…

Actually - 375 is the radius of the circle, if you look at the drawing - you’re right to divide the full area by 2 to make it half circle, but the radius of the half circle is still the full 375.

2 Likes