Algorithm check
for my input data type i changed it into Character since inputing a number in cube as radius can be referred in computer terminology as characters?
(i.e r³=6³ or 3³ and so on)
From my limited knowledge of programming, a character or char (Java) is a single character (i.e. single text character, letter or digit) but it isn't recognised as a number so that wouldn't be correct. If you were to enter the radius as a character, you would then have to convert it to a number data type (int, float, double etc) for use in the algorithm.
What I am getting at is more, is the radius a whole number? More often than not when measuring length, we do not measure whole numbers. We tend to measure to a decimal place. If you wanted the algorithm to do this, you can get more acurate results but the disadvantage is that more system memory is used when using floats or doubles as opposed to using an int for whole numbers. So where you can, use the smallest possible data type but you need to know the limitations of it. It would be quite common for someone to enter 6.3 as the radius but if you have r set to an int, the program will crash. So you would need to tell the user what format the radius should be input as if there are such limitations.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now