Java:j'ai besoin votre correction

Résolu/Fermé
domxaline - 1 mars 2012 à 20:37
 hichammoad - 4 nov. 2012 à 13:39
Bonjour,
bonjour
j'ai besoin votre correction sur ce énoncé:

*write a program that will read the value of x and evaluate the following function
{ 1 for x > 0
y = { 0 for x = 0
{ -1 for x < 0

using
a) nested if statements,
if(x>=0)
if(x>0)
y=1;
else
y=0;
else
y=-1;

b) else if statements,
If(x>0)
y=1;
Elseif (x=0)
y=0;
Else
y=-1


c) conditional operator ?....
y=(x !=0) ?((x<0) ?(-1) :(1)) :0

aidez moi svp


A voir également:

3 réponses

choubaka Messages postés 39377 Date d'inscription jeudi 4 avril 2002 Statut Modérateur Dernière intervention 12 mai 2024 2 101
2 mars 2012 à 10:13
Bonjour

Ne cherchez plus, voir ci-dessous

Almanach des corrections d'exercices Java Edition 2012
1
répondez moi svp
0
c) conditional operator :

y=(x >0) ? 1 : (x<0?-1:(0)) ;
0