Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. /**
  7. *
  8. * @author Adam Csatari
  9. */
  10. public class hazi {
  11. public static void main(String[] args) {
  12. double testmagassag;
  13. int testtomeg;
  14.  
  15.  
  16. //adatbekérés
  17.  
  18.  
  19. do {
  20. System.out.println("A testmagasság 100 és 200 cm között lehet csak ");
  21. testmagassag=extra.Console.readInt("Kérem a testmagasságot: ");
  22. } while (testmagassag<100 || testmagassag>200);
  23.  
  24. System.out.println("");
  25.  
  26.  
  27.  
  28. do {
  29. System.out.println("A testtomeg 40 és 150 kg között lehet csak ");
  30. testtomeg=extra.Console.readInt("Kérem a testtömeget: ");
  31. } while (testtomeg<40 || testtomeg>150);
  32.  
  33.  
  34.  
  35. System.out.println("");
  36.  
  37.  
  38.  
  39. //adatkiiratás
  40. System.out.println("Az Ön testmagassága: " +testmagassag + "cm");
  41. System.out.println("Az Ön testtömege: " +testtomeg + "kg");
  42.  
  43.  
  44. System.out.println("");
  45.  
  46. //adatkonvertálás
  47. double hanyados = (double) (testmagassag /100);
  48. double negyzet= (double) (hanyados*hanyados);
  49.  
  50.  
  51. //testömegindex szamolas
  52. double index = (double) (testtomeg / negyzet);
  53. System.out.println("Az Ön testtömeg indexe: " + index + "kg/m2");
  54.  
  55. //indexskala
  56. //20 alatt =sovány
  57. //20-25 között normál
  58. //25-30 között túlsúlyos
  59. //30-40 között elhízott
  60. //40 fölött kórosan elhízott
  61.  
  62.  
  63.  
  64. if (index<20)
  65. {
  66. System.out.println("Sovány");
  67. }
  68.  
  69.  
  70. else if (index<25 & index>20)
  71. {
  72. System.out.println("Normál");
  73. }
  74.  
  75. else if (index<30 & index>25)
  76. {
  77. System.out.println("Túlsúlyos");
  78. }
  79.  
  80. else if (index<40 & index>30)
  81. {
  82. System.out.println("Elhízott");
  83. }
  84.  
  85. else if(index>40)
  86. {
  87. System.out.println("Kórosan elhízott");
  88. }
  89.  
  90.  
  91.  
  92.  
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement