In this question we are going to calculate the surface area of a square and a circle as they change sizes. To get started: The purpose of this question (and of this assignment in general) is to practice writing and using functions with return values. So before you do anything else, you should write the following two functions: • circle_area(): This function should have a single parameter, d, which is the diameter of a circle. I should calculate and return the area of the circle with diameter d. Hint: Processing has a built-in variable called PI. It might help. • square_area(): This function should have a single parameter, w, which is the width of a square. I should calculate and return the area of the square. Once you have completed the two functions above, you should use them to build the following interactive program. While writing the rest of you program, do not ever duplicate the area formulas anywhere else Whenever you need to get the area of a shape, call one of these functions and use its return value. . When the program starts: Display a small circle and small square on the canvas. They should be different colors from each other, but can otherwise be of any color. If you make them look like cookies that's even better. . When the 'c' key is pressed: The diameter of the circle should increase by a small amount. . When the 's' key is pressed: The width of the square should increase by a small amount. . At all times: Display the current area of both shapes somewhere on the canvas. Call your functions that you wrote above to get the area, and simply display the value that they return.
In this question we are going to calculate the surface area of a square and a circle as they change sizes. To get started: The purpose of this question (and of this assignment in general) is to practice writing and using functions with return values. So before you do anything else, you should write the following two functions: • circle_area(): This function should have a single parameter, d, which is the diameter of a circle. I should calculate and return the area of the circle with diameter d. Hint: Processing has a built-in variable called PI. It might help. • square_area(): This function should have a single parameter, w, which is the width of a square. I should calculate and return the area of the square. Once you have completed the two functions above, you should use them to build the following interactive program. While writing the rest of you program, do not ever duplicate the area formulas anywhere else Whenever you need to get the area of a shape, call one of these functions and use its return value. . When the program starts: Display a small circle and small square on the canvas. They should be different colors from each other, but can otherwise be of any color. If you make them look like cookies that's even better. . When the 'c' key is pressed: The diameter of the circle should increase by a small amount. . When the 's' key is pressed: The width of the square should increase by a small amount. . At all times: Display the current area of both shapes somewhere on the canvas. Call your functions that you wrote above to get the area, and simply display the value that they return.
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
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education