Guest User

Untitled

a guest
Oct 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. package javaapplication23;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SitStudent {
  6.  
  7. static Scanner sc = new Scanner(System.in);
  8.  
  9. public static void main(String[] args) {
  10.  
  11. long stdID;
  12. String fname, sname;
  13. double weight, height;
  14.  
  15. System.out.print("Student ID :");
  16. stdID = sc.nextLong();
  17.  
  18. System.out.print("Name : ");
  19. fname = sc.next();
  20. System.out.print("SurName : ");
  21. sname = sc.next();
  22.  
  23. System.out.print("Weight : ");
  24. weight = sc.nextDouble();
  25. System.out.print("Height : ");
  26. height = sc.nextDouble();
  27.  
  28. Student std = new Student(stdID, fname, sname, weight, height);
  29. // System.out.println(std.toString());
  30. System.out.println(std.getFname());
  31. System.out.println(std.getsName());
  32. System.out.println(std.getWeight());
  33. System.out.println(std.getHeight());
  34.  
  35.  
  36. double bmi = bmiCal(std.getWeight(), std.getHeight());
  37.  
  38. System.out.println(bmi);
  39. System.out.println(hongkong(bmi));
  40.  
  41. System.out.println(std.getEmail());
  42. }
  43.  
  44. public static Double bmiCal(double weight, double height) {
  45.  
  46. double bmi = weight / ((height / 100) * (height / 100));
  47.  
  48. return bmi;
  49.  
  50. }
  51.  
  52. public static String hongkong(double bmi) {
  53. String cate = null;
  54. if (bmi < 18.5) {
  55. cate = "Underweight";
  56. }
  57. if (bmi >= 18.5 && bmi < 23) {
  58. cate = "Normal Range";
  59. }
  60. if (bmi >= 23 && bmi < 25) {
  61. cate = "Overweight-At Risk";
  62. }
  63. if (bmi >= 25 && bmi < 30) {
  64. cate = "Moderately Obese";
  65. }
  66. if (bmi >= 30) {
  67. cate = "Severely Obese";
  68. }
  69. return cate;
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment