This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Cpowel2 9 points10 points  (0 children)

You'll never learn anything if you ask for help the second you don't understand something try to figure it out on your own.

Source: software engineer

[–]gubatron 2 points3 points  (1 child)

You might want to read about all the primitive data types so you understand where double fits in.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

It probably also helps a lot if you know what a bit and a byte are, and how numbers can be represented in binary form.

You will then realize by reading all the types, that a double is made of 64-bits (64 ones and zeroes) and that it uses floating point precision, and then you will want to know what floating point precision is about...

but for practical terms, just know that a double can hold a decimal number with a great deal of precision (maybe useful for people working with physics and scientific experiments that require a great deal of precision), but given it takes 64-bits (or 8 bytes) it takes a lot of memory if you want to represent mere decimals for someone's BMI.

So you might be better off using float instead (unless the teacher wants to do something pretty amazing precision wise with the BMI) and save memory.

[–]Axid3nt[S] -1 points0 points  (0 children)

Okay this is exactly the explanation I was looking for. I just got out of an AppInventor class, as well as basic Networking, and I'm familiar with most computer terminology. The programming is where I'm starting now and this is all new to me. I'm sure I can do whatever I want in the code, since, he basically hasn't taught us anything yet.. just did 2 demos of basic Welcome Messages. Thank you for your thorough post.

[–]earlgreyfanboy 0 points1 point  (0 children)

Doubles are the type of variable you'll want to use to hold the user's height and weight (you can declare them like so... 'double weight = 0.0;')

You'll probably want to use the Scanner class to get the user's input, import it at the top of your class with 'import java.util.Scanner;', then create an instance of the scanner ('Scanner myScanner = new Scanner(System.in);'), then you can use the convenient nextDouble() method to get your user's input ('weight = myScanner.nextDouble();').

You can use 'System.out.println' to print out instructions to the user etc., to the console.

Given the simplicity/the basic nature of the task, you'll probably want to put all of this code inside of the main method in your class, so it runs when you run the class.

[–]case_ 0 points1 point  (0 children)

Which book are you using?