SHARE
TWEET

Untitled

a guest Jun 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SugarLevel {
  2.     private double sugarLevel;
  3.     private String condition;
  4.     private String classification;
  5.  
  6.     public void setSugarLevel(double sL){
  7.         sugarLevel =sL;
  8.     }
  9.     public Double getSugarLevel(){
  10.         return sugarLevel;
  11.     }
  12.  
  13.     public void setCondition(String c){
  14.         condition = c;
  15.     }
  16.     public String getCondition(){
  17.         return condition;
  18.     }
  19.  
  20.     public String calculateSugarLevelFasting(){
  21.         if(sugarLevel < 70){
  22.             classification = "Low";
  23.         }
  24.         else{
  25.             if(sugarLevel >= 70 && sugarLevel <=110){
  26.                 classification = "Normal";
  27.             }
  28.             else{
  29.                 if(sugarLevel >= 111 && sugarLevel <= 125){
  30.                     classification = "Pre-Diabetes";
  31.                 }
  32.                 else{
  33.                     if(sugarLevel > 125){
  34.                         classification = "Diabetes";
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.     return classification;
  40.     }    
  41.  
  42.     public String calculateSugerLevel2HAfterMeal(){
  43.         if(sugarLevel < 70){
  44.             classification = "Low";
  45.         }
  46.         else{
  47.             if(sugarLevel >= 70 && sugarLevel <=140){
  48.                 classification = "Normal";
  49.             }
  50.             else{
  51.                 if(sugarLevel >= 141 && sugarLevel <= 160){
  52.                     classification = "Pre-Diabetes";
  53.                 }
  54.                 else{
  55.                     if(sugarLevel > 160){
  56.                         classification = "Diabetes";
  57.                     }
  58.                }
  59.             }
  60.         }
  61.     return classification;
  62.     }
  63. }
  64.  
  65.  
  66. import java.util.Scanner;
  67. public class HealhtMonitoringSystem {
  68.     public static Scanner scan = new Scanner(System.in);
  69.  
  70.     public static void main(String[] args) {
  71.  
  72.         /*Sugar Level*/
  73.         SugarLevel sugar = new SugarLevel();
  74.         String c = null;
  75.         System.out.print("Enter Your Blood Sugar Level :");
  76.         double sl = scan.nextDouble();
  77.         sugar.setSugarLevel(sl);
  78.         sugar.getSugarLevel();
  79.  
  80.         System.out.println("1. Fasting");
  81.         System.out.println("2. 2 Hours After Meal");
  82.         System.out.print("Enter your condition : ");
  83.         String choice = scan.next();
  84.         sugar.setCondition(choice);
  85.         sugar.getCondition();
  86.  
  87.         if(choice == "Fasting"){
  88.             c =sugar.calculateSugarLevelFasting();
  89.             System.out.println(c);
  90.         }
  91.         else{
  92.             if(choice == "2 Hours After Meal"){
  93.                 c = sugar.calculateSugerLevel2HAfterMeal();
  94.                 System.out.println(c);
  95.             }
  96.         }
  97.     }  
  98. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top