Results 1 to 3 of 3
- 09-10-2008, 04:21 AM #1Member
- Join Date
- Sep 2008
- Rep Power
New to Programming . . .Need Help
For one of my classes I have to write basic Java code that will compute the area of a rectangle, triangle and circle. Here are the directions for the first:
The area of a rectangle is found by multiplying its ase and height. As such, define 3 integer variables in "main" : two for the base and height, and one for the area. Your program should read the base and height using the following format: Rectangle's base: 7 , Rectangle's height: 6 . . . and it should wrrite to the screen in the following format "the area of a rectangle of base 7 and height 6 is 42.
Continue extending your program by adding operations to calculate the area of a triangle.
The area of a triangle is found by multiplying its base and height and dividing this result by 2.
As such, define 3 additional variables in “main”: two integers for the base and height, and one double for the resulting area.
Your program should read the base and height using the following format
Triangle’s base: 21
Triangle’s height: 3
…and should write to the screen in the following format
The area of a triangle of base 21 and height 3 is 31.5
The area of a circle is found by multiplying the square of its radius by π. For simplicity, assume that the value of π is 3.14159. The square of the radius is calculated by multiplying it by itself.
As such, define 2 additional double variables in “main”: one for the radius, and one for the area.
Your program should read the radius using the following format
Circle’s radius: 5
…and write to the screen in the following format
The area of a circle of radius 5.0 is 78.53975
- 09-10-2008, 05:02 AM #2Member
- Join Date
- Jul 2008
- Rep Power
You aren't going to get anyone here to do your homework. If you make an attempt and can't figure something out post a more specific question and someone will be glad to help you with your problem.
- By abcdefg in forum New To JavaReplies: 9Last Post: 03-10-2008, 11:34 AM
- By Java Tutorial in forum Java TutorialReplies: 0Last Post: 02-11-2008, 05:04 PM
- By gibsonrocker800 in forum Forum LobbyReplies: 12Last Post: 01-17-2008, 11:58 PM
- By gt123 in forum New To JavaReplies: 4Last Post: 01-01-2008, 01:41 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 12-25-2007, 12:20 PM