Docsity

Programming Assignment: Calculating Areas of Circles, Squares, and Triangles, Assignments of Computer Science

Toggle sidebar
bg1
HOMEWORK 1: Programming assignment
Graded by Elizabeth White
Due Friday, February 7 by 5 PM by email
Modify the HelloWorld code you wrote in recitation. Remove the code that prompts the
user for a name and a year of birth. Instead, get a floating-point number from the user.
You’ll need to print a message to the screen, asking the user (that’s me) to enter a
number. Store this number in a float (decimal number) variable called r. To get the
number the user types in to convert to a float, you’ll need to parse it (this is similar to
what the original code does for the birth year). If this doesn’t make sense yet, come to
recitation on Monday and we’ll try to clarify things.
In your code, calculate and print out the area of a circle of radius r, a square with sides of
length r, and an equilateral triangle with sides of length r. Submit your code (the .java
file) and the executable (the .exe file) by email. We’ll talk about how to submit
homework code next Monday.

Partial preview of the text

Download Programming Assignment: Calculating Areas of Circles, Squares, and Triangles and more Assignments Computer Science in PDF only on Docsity!

HOMEWORK 1: Programming assignment Graded by Elizabeth White Due Friday, February 7 by 5 PM by email Email to: [email protected]

Modify the HelloWorld code you wrote in recitation. Remove the code that prompts the user for a name and a year of birth. Instead, get a floating-point number from the user. You’ll need to print a message to the screen, asking the user (that’s me) to enter a number. Store this number in a float (decimal number) variable called r. To get the number the user types in to convert to a float, you’ll need to parse it (this is similar to what the original code does for the birth year). If this doesn’t make sense yet, come to recitation on Monday and we’ll try to clarify things.

In your code, calculate and print out the area of a circle of radius r, a square with sides of length r, and an equilateral triangle with sides of length r. Submit your code (the .java file) and the executable (the .exe file) by email. We’ll talk about how to submit homework code next Monday.