Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use IBM Swift sandbox to check it before posting, thank you! A struct that implements the idea of a Circle struct Circle : CustomstringConvertible

image text in transcribedplease use IBM Swift sandbox to check it before posting, thank you!

A struct that implements the idea of a Circle struct Circle : CustomstringConvertible var radius: Double in it (radius: Double ) { self.radius = radius //return area of circle func area (O) ->Double returnDouble .pi radius * radius I/return circumference of circle func circumference (O) ->Double return 2 * Double-pi radius 1/return difference in area of this circle and a given circle func differenceInArea (. C: Circle ) - > Double return area () - C. area (O) //a textual representation of the circle var description: String return "radius: I (radius) area : (area ()) circumference : I (circumference (O) " I/Sample Test Code let c1 = Circle (radius: 5) let c2 = Circle (radius: 10) print ("Circle 1: A (Cl ) ") print ("Circle 2: A (C2 ) ") print ('Area difference between the two circles: \(ci.differenceInArea (c2))") print () var circles = [Circle] () circles.append (cl) circles.append (C2) circles.append (Circle (radius: 15)) for C in circles {print (c) } I/Test Code Results Circle 1 : radius: 5.0 area: 78.5398163397448 circumference: 31. 4159265358979 Circle 2: radius : 10.0 area: 314.1592 65358979 circumference : 62.8318530717959 Area difference between the two circles: -235.619449019234 radius : 5.0 area: 78.5398163397448 circumference : 31.4159265353 979 radius : 10.0 area : 314.1592 65358979 circumference: 62.8318530717959 radius: 15.0 area: 706.858347057703 circumference: 94.2477796076938 Program ended with exit code: 0

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

Step: 3

blur-text-image

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

1. Prepare a flowchart of Dr. Mahalees service encounters.

Answered: 1 week ago