Java Reference
In-Depth Information
while (((z - x) % 4) != 0)
{
System.out.print(z + " ");
z = z + 7;
}
System.out.println();
}
}
Suppose that the input is:
58 23 46 75 98 150 12 176 145 -999
What is the output of the following program?
import java.util.*;
12.
5
public class FindTheOutput
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int num;
num = console.nextInt();
while (num != -999)
{
System.out.print(num % 25 + "
");
num = console.nextInt();
}
System.out.println();
}
}
13. The following program is designed to input two numbers and output their
sum. It asks the user if he/she would like to run the program. If the answer
is Y or y , it prompts the user to enter two numbers. After adding the
numbers and displaying the results, it again asks the user if he/she would
like to add more numbers. However, the program fails to do so. Correct the
program so that it works properly.
import java.util.*;
public class Exercise13
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
char response;
double num1;
double num2;
Search WWH ::




Custom Search