
Show the output of the following
(a)
public class Test {
public static void main(String[] args) {
for (int i = 1; i < 5; i++) {
int j = 0;
while (j < i) {
System.out.print(j + " ");
j++;
}
}
}
}
(b)
public class Test {
public static void main(String[] args) {
int i = 0;
while (i < 5) {
for (int j = i; j > 1; j--)
System.out.print(j + " ");
System.out.println("****");
i++;
}
}
}
(c)
public class Test {
public static void main(String[] args) {
int i = 5;
while (i >= 1) {
int num = 1;
for (int j = 1; j <= i; j++) {
System.out.print(num + "xxx");
num *= 2;
}
System.out.println();
i--;
}
}
}
(d)
public class Test {
public static void main(String[] args) {
int i = 1;
do {
int num = 1;
for (int j = 1; j <= i; j++) {
System.out.print(num + "G");
num += 2;
}
System.out.println();
i++;
} while (i <= 5);
}
}
![Show the output of the following programs, (Hint: Draw a table and list the variables in the columns to trace
these programs.)
public class Test {
public static void main (String[] args) {
int i = 0:
while (i < 5) {
for (int j
Systes.out. print (j +
System.out.printin("*** **):
public class Test {
public static void main (String[] args) {
for (int i = 1: i < 5; i++) {
int j = 0:
while () < i} {
System.cut.print{j
j++:
= i; j > 1; --)
");
"):
i++:
(a)
(b)
public class Test {
public static void main (String[] args) {
publíc class Test {
public static void main(String[] args) {
int i = 5:
int i = 1:
while (i >= 1) (
do {
int num
1:
int num
= 1;
for (int j
for (int j
System.out.print(num + "xxx"):
į <= i: j++) {
System.out.print (num + "6");
1: j <= i: j++) {
%3D
%3D
*: 2:
num += 2;
num
System.out.printin():
System.out.printin():
i++;
i--:
} while (i <= 5):
(c)
(d)](https://content.bartleby.com/qna-images/question/3d0b0572-8d36-4468-a5b0-740b909e03c0/559a43b7-2ca7-4067-b96d-5eb7350321dd/jdajitm_thumbnail.jpeg)

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images

- Q2: Order of operations and math data types Use the Java IDE to create and run the following program: // Java program by [Student name] [Today's date] public class MathExample { public static void main(String[] args) { System.out.println(3/2+3); System.out.println(0.5*3+4/2); System.out.println(0.5*2/3+10/2); } } Please answer the following questions. What type of literal is 3: double or Integer? What type of literal is 0.5: double or integer? For the first expression, why is first value printed 4 instead of 4.5? For the second expression, which math operation is done last? Use parentheses to change the third expression so (3+10) is calculated first. Paste the revised expression here: Please give a full explanation of the program. Please keep in mind that I am a beginner and please keep it simple.arrow_forward(Intro to Java) 2. Pls help Thanksarrow_forwardusing System;class Program{ public static void Main(string[] args) { int number = 1; while (number <= 1000) { Console.WriteLine(number); number = number + 1; } }} this program counts from 1-1000 in C#. how would it be changed to use the += operator to add one to number, instead of writing number = number + 1?arrow_forward
- Identify what is X for the below program to return total. class Sample { static double calculateInterest (double amount) { assert amount > 0 && amount <= 1000; } double interest = 1.2; double total; total interest amount; O return total; public static void main(String[] args) { System.out.println (calculate Interest ( } a. -3.5 O b. 900.5 c. 2300 O d. 4001 8arrow_forwardFill in the blanks and be careful of the order of the outputarrow_forwardusing System;class Program{ public static void Main(string[] args) { int number = 1; while (number <= 1000) { Console.WriteLine(number); number = number + 1; } }} This program is written for C# to count from 1-1000. How would this program be rewritten to get numbers from the user until the user enters 0?arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





