Results 1 to 3 of 3
 09102008, 04:21 AM #1Member
 Join Date
 Sep 2008
 Posts
 3
 Rep Power
 0
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
Dan
 09102008, 05:02 AM #2Member
 Join Date
 Jul 2008
 Posts
 68
 Rep Power
 0
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.

Similar Threads

programming
By abcdefg in forum New To JavaReplies: 9Last Post: 03102008, 10:34 AM 
Applet Programming
By Java Tutorial in forum Java TutorialReplies: 0Last Post: 02112008, 04:04 PM 
Programming buddy
By gibsonrocker800 in forum Forum LobbyReplies: 12Last Post: 01172008, 10:58 PM 
Programming a Game?
By gt123 in forum New To JavaReplies: 4Last Post: 01012008, 12:41 PM 
Programming block
By Java Tip in forum Java TipReplies: 0Last Post: 12252007, 11:20 AM
Bookmarks