+ 1

Is it worth separating BMI and person classes?

See below to see how I can clean this up to use as a larger program to enter into my repertoire to use later on. import java.awt.Color; import java.awt.color.*; import java.util.Scanner; public class Person { protected int age = 0; protected int height = 0; protected int weight = 0; private int leglength = 0; private int armlength = 0; public double bmi = 0; private Color Eyecolor = Color.green; protected String gender = null; private String bodytype = null; private String headshape = null; private boolean Person ; public static void main(String[] args) { int weight = 0; int height = 0; int bmi = 0; String Bmi = null; Scanner input = new Scanner(System.in); Person person = new Person(); System.out.print("Enter your Height: " ); height = input.nextInt(); System.out.print("Enter your Weight: "); weight = input.nextInt(); bmi = ((weight* 703)/(height * height)); System.out.println("Your BMI is:" + bmi); if(bmi<18.5) Bmi = "Underweight"; else if(bmi > 18.5 && bmi <24.9) Bmi = "Normal"; else if(bmi > 24.9 && bmi<29.9) Bmi = "Overweight"; else { Bmi = "Obese"; } System.out.print("You are " + Bmi); } }

10th Feb 2019, 5:01 PM
trevor whitlock
trevor whitlock - avatar
4 Respuestas
0
Sorry about that. I will remember to do this from now on thanks for the advice. https://code.sololearn.com/chWuWW6oZadh/?ref=app
10th Feb 2019, 5:59 PM
trevor whitlock
trevor whitlock - avatar
0
Ok I will take a crack at it again. I am still learning structure and the benefits of said structure.
10th Feb 2019, 6:13 PM
trevor whitlock
trevor whitlock - avatar
0
I am working on this to creat a robust goto for future code reference and possible easy plug options as I learn more. Currently since I completed the tutorial and have the certificate I am having a go at the IBM resources for Java programming. I figure what is simple to cut out can be done and written during coding and any complex parts I come across I can save to reference later.
10th Feb 2019, 6:21 PM
trevor whitlock
trevor whitlock - avatar
0
Thank you. Well thought out answer. I was thinking of leaning that way since it was very easy to write the BMI methods and it is easy to find on the net. That being said it would seem to be a waste of memory. I am starting to see that programming is a game of tradeoffs so I better get used to it.
11th Feb 2019, 10:10 AM
trevor whitlock
trevor whitlock - avatar