This is my task, and I'm trying to do that with the short if-statements only, the only error I get is that with the syntax where there's "(0.5<=ratio<2)", other than that, Is the construction right?
Scanner scn = new Scanner(System.in);
int years,kg,cm,MenuA,MenuB,MenuC,A,B,C;
String not;
double ratio = cm/kg;
System.out.println("Please enter your age (years), weight(kg) and height(cm) in that order with spaces");
years = scn.nextInt();
kg = scn.nextInt();
cm = scn.nextInt();
MenuA = (20<years<<11||40<<years<21)&&(0.5<=ratio<2)?A:MenuB;
MenuB = (20<years<<11)&&(2<=ratio<<3.5)?B:MenuC;
MenuC = (40<<years<21)&&(2<=ratio<<3.5)?C:not;
}
}
Aucun commentaire:
Enregistrer un commentaire