Jump to content

Methods... think I over did it on the last one

- - - - -

  • Please log in to reply
4 replies to this topic

#1
wolfman

wolfman

    Newbie

  • Members
  • PipPip
  • 18 posts
The point of this program is to calculate a players body mass index (BMI). We're just suppose to calculate and display the total, but we're suppose to use five methods. I feel good about the first four, but I wasn't too sure about the last one. This is all done in PSEUDO CODE.

class BMICalculator

	main()

	     //Declarations

		num weight	

		num height

	

	     weight = getPlayerWeight()

	     height = getPlayerHeight()

	     calBMI = getCalBMI (weight, height)

	     displayBMI(calBMI)


	     output “Welcome to the Body Mass Index Calculator”

     	return

	

	num getPlayerWeight()

	     //Declarations

		num playerWeight

	     output “Please enter your weight in lbs. : ”

	     input playerWeight

	return playerWeight


	num getPlayerHeight()

	     //Declarations

		num playerHeight

	     output “Please enter your height in inches : ”

	     input playerHeight

	return playerHeight


	num getCalBMI(num weight, num height)

	     //Declarations

		num calculatedBMI

		calBMI = (weight/(height*height)) * 703

	return calculatedBMI                            


	displayBMI (num displayResults)

	     //Declarations

                num displayResults

                displayResults = calBMI

	     output “Your body mass index (BMI) is: ” calBMI

	return

	

endClass 


Thanks
-=[ w | o | l | f | m | a | n ]=-

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
In displayBMI, you already have displayResults as calBMI, by virtue of how it's called. All you need is
output "Your body mass index (BMI) is: " displayResults

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
wolfman

wolfman

    Newbie

  • Members
  • PipPip
  • 18 posts

WingedPanther said:

In displayBMI, you already have displayResults as calBMI, by virtue of how it's called. All you need is
output "Your body mass index (BMI) is: " displayResults

Made the adjustment, that's exactly what I had did at first. I just started getting confused towards the end with all the parameters and variables I was using and creating.

Thank you,

-=wolfman
-=[ w | o | l | f | m | a | n ]=-

#4
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
Are you allowed to consider "Main()" as a function. I understand that essentially it is a function but were you supposed to have 5 functions other than your main?
-CDG10620
Software Developer

#5
wolfman

wolfman

    Newbie

  • Members
  • PipPip
  • 18 posts

cdg10620 said:

Are you allowed to consider "Main()" as a function. I understand that essentially it is a function but were you supposed to have 5 functions other than your main?

I probably should of elaborated more on the directions, but yes, main() is one of the five methods.

-=wolfman
-=[ w | o | l | f | m | a | n ]=-




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users