mardi 3 décembre 2019

Substituting if-else for switch statement

Could I have help with producing a switch statement from the following:

if (D != 0)  
{ 

    // Coeff have a unique solution. Apply Cramer's Rule 
    double x = DX / D; 
    double y = DY / D; 
    double z = DZ / D; // calculating z using cramer's rule 
    System.out.printf("Value of x is : %.6f\n", x); 
    System.out.printf("Value of y is : %.6f\n", y); 
    System.out.printf("Value of z is : %.6f\n", z); 
}//if

else 
{ 
    if (DX == 0 && DY == 0 && DZ == 0) 
        System.out.printf("Infinite solutions\n"); 
    else if (DX != 0 || DY != 0 || DZ != 0) 
        System.out.printf("No solutions\n"); 
}//else 

......Thanks...…..

Aucun commentaire:

Enregistrer un commentaire