Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SugarLevel {
- private double sugarLevel;
- private String condition;
- private String classification;
- public void setSugarLevel(double sL){
- sugarLevel =sL;
- }
- public Double getSugarLevel(){
- return sugarLevel;
- }
- public void setCondition(String c){
- condition = c;
- }
- public String getCondition(){
- return condition;
- }
- public String calculateSugarLevelFasting(){
- if(sugarLevel < 70){
- classification = "Low";
- }
- else{
- if(sugarLevel >= 70 && sugarLevel <=110){
- classification = "Normal";
- }
- else{
- if(sugarLevel >= 111 && sugarLevel <= 125){
- classification = "Pre-Diabetes";
- }
- else{
- if(sugarLevel > 125){
- classification = "Diabetes";
- }
- }
- }
- }
- return classification;
- }
- public String calculateSugerLevel2HAfterMeal(){
- if(sugarLevel < 70){
- classification = "Low";
- }
- else{
- if(sugarLevel >= 70 && sugarLevel <=140){
- classification = "Normal";
- }
- else{
- if(sugarLevel >= 141 && sugarLevel <= 160){
- classification = "Pre-Diabetes";
- }
- else{
- if(sugarLevel > 160){
- classification = "Diabetes";
- }
- }
- }
- }
- return classification;
- }
- }
- import java.util.Scanner;
- public class HealhtMonitoringSystem {
- public static Scanner scan = new Scanner(System.in);
- public static void main(String[] args) {
- /*Sugar Level*/
- SugarLevel sugar = new SugarLevel();
- String c = null;
- System.out.print("Enter Your Blood Sugar Level :");
- double sl = scan.nextDouble();
- sugar.setSugarLevel(sl);
- sugar.getSugarLevel();
- System.out.println("1. Fasting");
- System.out.println("2. 2 Hours After Meal");
- System.out.print("Enter your condition : ");
- String choice = scan.next();
- sugar.setCondition(choice);
- sugar.getCondition();
- if(choice == "Fasting"){
- c =sugar.calculateSugarLevelFasting();
- System.out.println(c);
- }
- else{
- if(choice == "2 Hours After Meal"){
- c = sugar.calculateSugerLevel2HAfterMeal();
- System.out.println(c);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement