Riki Maru

Greenhorn

Posts: 5

posted 2 years ago

Make a Program that can calculate the area and perimeter based on the choice selected.

Example:

Menu:

1.Square

2.Triangle

3.Circle

Select: 1

Triangle Menu:

1.Area

2.Perimeter

Select: 1

Input side : 5

Result : 25

This is the question. i dont really understand the question but this has to be submitted by today night . If anyone can help me that would be great

Example:

Menu:

1.Square

2.Triangle

3.Circle

Select: 1

Triangle Menu:

1.Area

2.Perimeter

Select: 1

Input side : 5

Result : 25

This is the question. i dont really understand the question but this has to be submitted by today night . If anyone can help me that would be great

Campbell Ritchie

Marshal

Posts: 56546

172

Mike. J. Thompson

Bartender

Posts: 689

17

posted 2 years ago

Well the question is asking you to give the user some options, then calculate the result based on those options.

So you need to ask the user to pick a shape, ask the user to pick a measurement (perimeter or area), then ask the user to give the side length of the shape.

So do you know how to get input from the user? I would start simple and just ask the user to pick a shape and then print back their choice to them. You can build from there.

So you need to ask the user to pick a shape, ask the user to pick a measurement (perimeter or area), then ask the user to give the side length of the shape.

So do you know how to get input from the user? I would start simple and just ask the user to pick a shape and then print back their choice to them. You can build from there.

Robert D. Smith

Ranch Hand

Posts: 221

5

posted 2 years ago

This seems fairly straightforward, although your instructions on finding the area of a triangle appear to be incorrect (if I understand it correctly).

My suggestion, to expound on Campbell's advice is to turn off the computer, find a pencil (or a pen depending on your confidence level) and start with figuring out the math, which will help you narrow down what you are going to need in the form of methods, properties, etc. Calculating the area of a square is different than calculating the area of a triangle is different than calculating the area of a circle. The same applies to figuring out the perimeter/circumference.

Going back to my comment on the triangle above. Your example appears to take only a single input for the area calculation, but the math is Area = (base * height) / 2;so you will need more than a single input. Once you have that laid out, the code will fall into place.

Regards,

Robert

My suggestion, to expound on Campbell's advice is to turn off the computer, find a pencil (or a pen depending on your confidence level) and start with figuring out the math, which will help you narrow down what you are going to need in the form of methods, properties, etc. Calculating the area of a square is different than calculating the area of a triangle is different than calculating the area of a circle. The same applies to figuring out the perimeter/circumference.

Going back to my comment on the triangle above. Your example appears to take only a single input for the area calculation, but the math is Area = (base * height) / 2;so you will need more than a single input. Once you have that laid out, the code will fall into place.

Regards,

Robert

There are worse crimes than burning books. One of them is not reading them. Ray Bradbury

Mike. J. Thompson

Bartender

Posts: 689

17

Campbell Ritchie

Marshal

Posts: 56546

172

posted 2 years ago

They call

You can work that out from sideRobert D. Smith wrote: . . . Area = (base * height) / 2 . . .

*a*× side

*b*× sin(angleC) ÷ 2 but that requires use of the cosine rule to calculate the angle, if you have three sides. There is another method which seems to be called Heron's formula.

They call

*s*semiperimeter, so you should use the perimeter to calculate it..