C Sharp How do I format my code to 2 decimal places whem I am calling my code in Main  using System.Threading.Tasks; namespace ssullivan_A2_1.cs{    class Program    {        //The output should display the Object Type (Circle, Square or Triangle)        //the values used to initialize the shape, the area, and the perimeter         static void Main(string[] args)        {    ////Store the objects in a Collection object (List, Array, HashSet, etc...) objects in the collection will be of type Shape            Shapes[] arrayOfShapes = new Shapes[3];             arrayOfShapes[0] = new Circle(5);//             arrayOfShapes[1] = new Rectangle(5, 5);//             arrayOfShapes[2] = new Triangle(3, 5, 5);//              //the values used to initialize the shape, the area, and the perimeter             foreach (Shapes objects in arrayOfShapes)            {// use arrayOfShapes to call methods                  //The output should display the Object Type (Circle, Square or Triangle)                //the values used to initialize the shape, the area, and the perimeter                                // use objects to call functions (                //GetType().Name} returns the name of the object                 // use $ and { } when calling the object with the fubction                 Console.WriteLine($"The area of {objects.GetType().Name} is: {objects.CalculateArea() }");                Console.WriteLine($"The perimeter of {objects.GetType().Name} is: {objects.CalculatePerimeter()}");             }         }                  The area of Circle is: 19.6349540849362    // I want this to be 2 decimal places The perimeter of Circle is: 15.707963267949  //I want this to be 2 decimal places The area of Rectangle is: 25The perimeter of Rectangle is: 20The area of Triangle is: 0The perimeter of Triangle is: 11Press any key to continue . . .

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C Sharp How do I format my code to 2 decimal places whem I am calling my code in Main 

using System.Threading.Tasks;

namespace ssullivan_A2_1.cs
{
    class Program
    {
        //The output should display the Object Type (Circle, Square or Triangle)
        //the values used to initialize the shape, the area, and the perimeter 
        static void Main(string[] args)
        {    ////Store the objects in a Collection object (List, Array, HashSet, etc...) objects in the collection will be of type Shape
            Shapes[] arrayOfShapes = new Shapes[3];

            arrayOfShapes[0] = new Circle(5);// 
            arrayOfShapes[1] = new Rectangle(5, 5);// 
            arrayOfShapes[2] = new Triangle(3, 5, 5);// 

            //the values used to initialize the shape, the area, and the perimeter 
            foreach (Shapes objects in arrayOfShapes)
            {// use arrayOfShapes to call methods 

                //The output should display the Object Type (Circle, Square or Triangle)
                //the values used to initialize the shape, the area, and the perimeter 
               
                // use objects to call functions (
                //GetType().Name} returns the name of the object 
                // use $ and { } when calling the object with the fubction 
                Console.WriteLine($"The area of {objects.GetType().Name} is: {objects.CalculateArea() }");
                Console.WriteLine($"The perimeter of {objects.GetType().Name} is: {objects.CalculatePerimeter()}");

            }

        }
        
        

 The area of Circle is: 19.6349540849362    // I want this to be 2 decimal places 
The perimeter of Circle is: 15.707963267949  //I want this to be 2 decimal places 
The area of Rectangle is: 25
The perimeter of Rectangle is: 20
The area of Triangle is: 0
The perimeter of Triangle is: 11
Press any key to continue . . .

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Avoiding deadlock
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education