which of the following code segments could replace the while loop without changing the resulting value of total?
I. for (int h = 0; h < num; h++)
{
total += num % 10;
num /= 10;
}
II. for (int j = num; j > 0; j--)
{
total += j % 10;
}
III. for (int k = num; k > 0; k /= 10)
{
total += k % 10;
}
A. I only
B. II only
C. III only
D. I and II
E. II and III

Respuesta :

Using the knowledge in computational language in JAVA it is possible to write a code that code segments could replace the while loop without changing the resulting value of total.

Writting the code:

import java.io.*; //Code Segment I

public class Main

{

public static void main(String[] args)

{

for (int i = 0; i < 10; i++)

{

System.out.print( "*" );

}

}

}

import java.io.*;

public class Main

{

public static void main(String[] args)

{

for (int i = 1; i <= 10; i++)

{

System.out.print( "*" );

}

}

}

See more about JAVA at brainly.com/question/12975450

#SPJ1

Ver imagen lhmarianateixeira