Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Java Programming Help?
I Need Help Writing A Program using the following information. I already have the Data file saved on my computer to.
From an article from the Mathematics Teacher, February 1981. Knowing the exact physical dimensions of a victim of a crime is extremely useful in identifying the victim. When a skeleton is found, a forensic scientist uses the lengths of certain bones to calculate the height of the living person. The bones that are used are the femur (F), the tibia (T), the humerus (H), and the Radius (R). When the length of one of these bones is known, one of the following formulas is used to determine the height. All measurements are in centimeters.
Male
h= 69.089 + 2.238 X F
h= 81.688 + 2.392 X T
h = 73.570 + 2.970 X H
h = 80.405 + 3.650 X R
Female
h = 61.412 + 2.317 X F
h = 72.572 + 2.533 X T
h = 64.977 + 3.144 X H
h = 73.502 + 3.876 X R
.After the age of thirty, the height of a person begins to decrease at the rate of approximately 0.06 cm per year. This shrinkage must be considered when the age of the victim is known.
Write a program that will determine the height of a person from provided data. The data will consist of a lead value indicating the number of bones to be analyzed. Data for each bone will consist of the following information:
1. Male or female (F or M)
2. Type of bone (F, T, H, or R)
3. Estimated age of person
4. Length of bone
Sample Output (What It Should Look Like)
sex bone age length height
F H 45 36.266 178.097
M F 18 46.967 174.201
M H 29 33.309 172.498
M T 95 36.983 166.251
M R 30 23.177 165.000
F F 31 42.550 159.940
F F 65 39.960 151.899
F T 50 30.962 149.799
F R 80 19.375 145.600
M H 3 624.017 144.540
Q F 40 30.000 Wrong Sex Code
M Q 40 30.000 Wrong Bone Code
1 Answer
- Anonymous1 decade agoFavorite Answer
I would go about doing something like this. The only thing I didn't do was the "Wrong Sex Code" and "Wrong Bone Code". I'm thinking of how to do this, since height is a type double, and can't output a String easily. BTW, what do you do if both the sex and bone type are wrong?
EDIT: OK I guess this way will work. I added some if else statements for what the height output will be, where heightoutput is a String. If everything is fine, heightoutput is the height made into a String.
public class Bones {
public String findHeight(char sex, char bone, int age, double length) {
double height = 0;
if (sex == 'M') {
switch (bone) {
case 'F':
height = 69.089 + (2.238 * length);
break;
case 'T':
height = 81.688 + (2.392 * length);
break;
case 'H':
height = 73.570 + (2.970 * length);
break;
case 'R':
height = 80.405 + (3.650 * length);
break;
}
} else if (sex == 'F') {
switch (bone) {
case 'F':
height = 61.412 + (2.317 * length);
break;
case 'T':
height = 72.572 + (2.533 * length);
break;
case 'H':
height = 64.977 + (3.144 * length);
break;
case 'R':
height = 73.502 + (3.876 * length);
break;
}
}
if (age > 30) {
int years = age - 30;
height = height - (years * .06);
}
if((sex != 'M') && (sex != 'F')){
heightOutput = "Bad Sex Code";
}
else if((bone != 'F') && (bone != 'T') && (bone != 'H') && (bone != 'R')){
heightOutput = "Bad Bone Code";
}
else{
heightOutput = Double.toString(height);
}
return sex + "\t" + bone + "\t" + age + "\t" + length + "\t" + heightOutput + "\n";
}
public static void main(String[] args) {
Bones b = new Bones();
System.out.println("sex \t bone \t age \t length \t height");
System.out.println(b.findHeight('F', 'H', 45, 36.266));
System.out.println(b.findHeight('M', 'F', 18, 46.967));
System.out.println(b.findHeight('M', 'H', 29, 33.309));
System.out.println(b.findHeight('M', 'T', 95, 36.983));
System.out.println(b.findHeight('M', 'R', 30, 23.177));
System.out.println(b.findHeight('F', 'F', 31, 42.550));
System.out.println(b.findHeight('F', 'F', 65, 39.960));
System.out.println(b.findHeight('F', 'T', 50, 30.962));
System.out.println(b.findHeight('F', 'R', 80, 19.375));
System.out.println(b.findHeight('M', 'H', 3, 624.017));
System.out.println(b.findHeight('Q', 'F', 40, 30.000));
System.out.println(b.findHeight('M', 'Q', 40, 30.000));
}
}