Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-question 1 to 15. What is the output each code? final int MIN = 10, MAX = 20;int num = 15;1. while (num < MAX) {System.out.print(num + “ “);num++;}2. while (num < MAX) {num++;System.out.print(num + “ “);}3. do {num++;System.out.print(num + “ “);} while (num <= MAX);4. while (num < MAX) {System.out.print(num + “ “);num--;}5. while (num > MIN) {System.out.print(num + “ “);num--;}6. while (num < MAX) {System.out.print(num + “ “);num += 2;}7. while (num < MAX) {if (num%2 == 0)System.out.print(num + “ “);num++;}8. do {num = num + 1;if (num * 2 > MAX + num)System.out.print(num + “ “);} while (num <= MAX);9. for (int value = 0; value >= 7; value++)System.out.print(value + “ “);10. for (int value = 7; value < 0; value--)System.out.print(value + “ “);11. for (int value = 1; value >= 20; value+=4)System.out.print(value + “ “);12. for (int value = num; value <= MAX; value++)System.out.print(value + “ “);13. for (int value = num; value <= MAX; value++)if (value%4 != 0)System.out.print(value + “ “);14. for (int value = MIN; value <= MAX; value++)if (value%4 == 0 && value%5 != 0)System.out.print(value + “ “);15. for (int value = MAX; value >= MIN; value -= 3)System.out.print(value + “ “);

Question
Asked Mar 28, 2019
16 views

Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-question 1 to 15. What is the output each code? 

final int MIN = 10, MAX = 20;
int num = 15;
1. while (num < MAX) {
System.out.print(num + “ “);
num++;
}
2. while (num < MAX) {
num++;
System.out.print(num + “ “);
}
3. do {
num++;
System.out.print(num + “ “);
} while (num <= MAX);
4. while (num < MAX) {
System.out.print(num + “ “);
num--;
}
5. while (num > MIN) {
System.out.print(num + “ “);
num--;
}
6. while (num < MAX) {
System.out.print(num + “ “);
num += 2;
}
7. while (num < MAX) {
if (num%2 == 0)
System.out.print(num + “ “);
num++;
}

8. do {
num = num + 1;
if (num * 2 > MAX + num)
System.out.print(num + “ “);
} while (num <= MAX);
9. for (int value = 0; value >= 7; value++)
System.out.print(value + “ “);
10. for (int value = 7; value < 0; value--)
System.out.print(value + “ “);
11. for (int value = 1; value >= 20; value+=4)
System.out.print(value + “ “);
12. for (int value = num; value <= MAX; value++)
System.out.print(value + “ “);
13. for (int value = num; value <= MAX; value++)
if (value%4 != 0)
System.out.print(value + “ “);
14. for (int value = MIN; value <= MAX; value++)
if (value%4 == 0 && value%5 != 0)
System.out.print(value + “ “);
15. for (int value = MAX; value >= MIN; value -= 3)
System.out.print(value + “ “);

check_circle

Expert Answer

Step 1

Hey, since there are multiple questions posted, we will answer first question. If you want any specific question to be answered then please submit that question only or specify the question number in your message or repost it again from which you want.

Here, I have solved first seven Question.

The given JAVA program is compiled in Eclipse software.

1.

Explanation:

  • Definition of class named “LoopMinMax”.
    • Definition of “main()” method.
      • Declaration of required variables.
      • “while” loop to check “num” is lesser than “MAX”.
        • If the condition is true in while loop, the loop iterate till the condition becomes false.
        • Print the “num” values.
        • Increment “num” value by 1.
      • If the condition is false, the loop exit and the program will be terminated.
Step 2

Program:

// Definition of class

public class LoopMinMax {

 

    // Definition of main() method

    public static void main(String args[]) {

   

    // Declaration and initialization of MIN and MAX

    final int MIN = 10, MAX = 20;

   

    // Declaration of initialization of num

    int num = 15;

   

    // While loop checks num is lesser than MAX

    while (num < MAX) {

        

         // Print the numbers

         System.out.print(num + " ");

        

         // Increment num

         num++;

    }

    }

}

Output:

fullscreen
Step 3

2.

Explanation:

  • Definition of class named “LoopMinMax”.
    • Definition of “main()” method.
      • Declaration of required variables.
      • “while” loop to check “num” is lesser than “MAX”.
        • If the condition is true in while loop, the loop iterate till the condition becomes false.
        • Increment “num” value by 1.
        • Print the “num” values.
      • If the condition is false, the loop exit and the program will be terminated.

Program:

// Definition of class

public class LoopMinMax {

 

    // Definition of main() method

    public static void main(String args[]) {

   

    // Declaration and initialization of MIN and MAX

    final int MIN = 10, MAX = 20;

   

    // Declaration of initialization of num

    int num = 15;

   

    // Whil...

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
question_answer

Q: Problem: Develop a class encapsulating the concept of a college course, assuming that a course has f...

A: The program has the following algorithm: Course.javaCreate default constructors.Test the “set” metho...

question_answer

Q: 1.1 Show that the following sets satisfy the law of contradiction and law ofexcluded middle.X = {a, ...

A: The law of contradiction satisfies the condition: A ∩ `A = ϕThe law of excluded middle satisfies the...

question_answer

Q: how to put a picture to top right corner in HTML

A: HTML stands for Hypertext markup language and is mainly used to format web pages and web sites. Html...

question_answer

Q: Assume that an array of integers named a that contains exactly five elements has been declared and i...

A: Didn’t mention which language to do the problem. So, did the problem in Java.Given:Let assume an arr...

question_answer

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz = 2; y= z+x;en...

A: Pass by value copies the value of argument and passes it to the parameter. Hence, the final value of...

question_answer

Q: Write a python code of a function that takes in four points in a counterclockwise order, a, b, c, d ...

A: Program Instructions:Create a function isConvex() and pass the four points as arguments.Save the par...

question_answer

Q: in Operating System1.Why are two modes (user and kernel) needed?2.What are the steps performed by an...

A: Reasons why two modes are needed in OS:The two modes of OS are user mode and kernel mode. The user m...

question_answer

Q: Read in 5 numbers from the keyboard and, if any of the entered numbers is &lt; 0, then print out “Ne...

A: Pseudo code is given below to read five numbers from the keyboard and print “Negative” if the number...

question_answer

Q: Create a new file in C++ and save it as lab12_XYZ.cpp  Consider rolling two six-sided dice. Whil...

A: Program Instructions:Declare the header files, constants, and prototypes.In main() call functions di...

question_answer

Q: Which command can you use to determine who is logged in on a specific terminal?

A: Different commands are used to determine who is logged in on a specific terminal. These commands are...

question_answer

Q: Transform the grammar S → aSaaA|A, A → abA|bb into Chomsky normal form.

A:  For solving your problem , first of all we will discuss about  algorithm to convert grammar into  C...

question_answer

Q: Write a complete C++ program that randomly generates 20 integers between the rangeof 1 to 50 and sto...

A: The random number is generated by using rand() function from stdlib.h and in order to generate a new...

question_answer

Q: Define a class called Player that implements Comparable &lt;Player&gt; with health and name attribut...

A: The question posed here is an extremely long and complex one, so we have judiciously attempted to pr...

question_answer

Q: List the octal and hexadecimal numbers from 1410 to 3210. Using A and B for the last two digits, lis...

A: Answer:Listing octal values from 1410 to 3210:Divide 14 by 8 (octal number) giving 1 remainder 61 is...

question_answer

Q: Load “Lock5Data” into your R console. Load “OlympicMarathon” data set in“Lock5Data”. This data set c...

A: First we install the Lock5Data package and then load the package. Then we load the library dplyr to ...

question_answer

Q: What form of storage doses a password manger store encrypted passwords? Is it local, web sites, clod...

A: Passwords managers allows one to generate strong and unique passwords and store them in one safe pla...

question_answer

Q: Cosc 1337 java Perform program setup and initializations- Prompt the user and input the starting Cel...

A: Note: The given program is compiled and executed in "NetBeans IDE"

question_answer

Q: Write a program called LoopMinMax that reads in 4 values from the user and prints the lowest and hig...

A: You didn’t mention which language should be used for the given program. Here, I have used JAVA langu...

question_answer

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz = 2; y= z+x;en...

A: Solution:Pass by name:Pass by name is a mechanism which is used by Algol programming language that e...

question_answer

Q: Use eclipse for these methods

A: Solution:Given data,The java code to display the output for method calls using the method overloadin...

question_answer

Q: Visual Basic. Given two variables, isEmpty of type boolean, indicating whether a class roster is emp...

A: We have to check two conditions:-1) class roster is not empty 2) The class has more than two credits...

question_answer

Q: Code should be in C++ Absolute Value Template: Write a function template that accepts an argument an...

A: Since Function Templates are used to handle all possible data types you can say generic data type at...

question_answer

Q: What is the best way to pass 2D arrays to a function? (C++) For my program, I have a 2D array (size:...

A: There are two ways to pass 2-D array to a function either by sending the array name in the function ...

question_answer

Q: do big data could replace the artistic vision of a creative director? and why?

A: Justification:“Yes”, big data replace the artistic vision of a creative director.

question_answer

Q: Use Java to answer the question. 5-1) (Count positive and negative numbers and compute the average o...

A: Java codeimport java.util.Scanner; public class AvgWithLoop {      public static void main(String[] ...

question_answer

Q: what strategies that would attract buyers to a company's e-commerce web site

A: Strategies to attract buyers to the company e-commerce website:Offer limited time specials to new cu...

question_answer

Q: how is macro work in word 2016

A: At first we need to enable the developer Tab if it's not enabled previously.Next, we need to click t...

question_answer

Q: Write a GUI application that calculates a car’s gas mileage. The application should let the user ent...

A: Create the MPGCalculator class and declare the given fields along with two JPanel gallonsLabel and m...

question_answer

Q: (Latest Revision: Apr 01, 2019) MST Problems First MST Problem:Suppose G=(V,E) is a connected undire...

A: Given (Table):According to the kruskal’s algorithm:Arrange every edge in increasing order of their w...

question_answer

Q: Construct npda that accept the following languages on Σ = {a, b, c}: L = {wcwR : w ∈ {a, b}∗}.

A: Non-deterministic pushdown automaton (NPDA):Given: L = {wcwR : w ∈ {a, b}∗}To construct NPDA, when “...

question_answer

Q: What’s the difference between integer, Floating point, and integer variable length? And how do I cal...

A: Assuming you are working in C language the explanation for the two data types integer and floating p...

question_answer

Q: Assignment: Check the Sample run first, then carefully read the instructions and write aprogram that...

A: Solution:Given data,The java code gets the first name, last name, and secret number to generate the ...

question_answer

Q: write a program to convert between KPH and MPH in either direction. in Eclipse.If you are driving ac...

A: Hey,,,We  have to use scanner class  to get input .So we will import scanner package to access the s...

question_answer

Q: Using Math.max and/or Math.min, write a class MaxOrMin, and make sure touse Math.max and Math.min wh...

A: Java codeimport java.util.Scanner; public class MaxOrMin {public static void main(String[] args){Sca...

question_answer

Q: how to to assign charather to perform additions (+), subtractions (-), multiplications (*), division...

A: Program plan:Include necessary header files.Declare the “namespace”.Define the “main()” function.Dec...

question_answer

Q: Please write Lisp code for the following problem. Write a function that computes the surface area of...

A: Instructions to create a function that computes the surface area of a cylinder:Define a function nam...

question_answer

Q: As an IT manager, what strategy would you have followed to avoid the failed implementation of ERP sy...

A: ERP system:It denotes software for business process management that permits an organization in using...

question_answer

Q: Function Name: leapYear Parameters: year – an nonnegative integer representing the year Test Cases: ...

A: Click to see the answer

question_answer

Q: how to write a function in python 3 using for loop that counts how many times a consonant (either lo...

A: Note: The given program is compiled and executed in "repl.it" online compiler.

question_answer

Q: Design a program that prompts user enters user name and password. Until user entered user name as "F...

A: Note: The given program is compiled and executed in "NetBeans IDE"

question_answer

Q: Find all strings in L ((a + bb)∗) of length five.

A: Answer:The symbol “+”denoted as “OR” operator which means “a + b” means either “a” or “b”, so the la...

question_answer

Q: I am trying to read in a text file called "lines.txt" that holds an entire dictionary of words with ...

A: First you need to use the ifstream class object to read from file.

question_answer

Q: example:"apple-&gt;orange-&gt;banana-&gt;pear"-&gt;NULLreturn "orange"Thanks!

A: ApproachIn the function longest(), we'll declare an integer named highestLength and assign 0 to it.N...

question_answer

Q: Normalization               Repair the ER Diagrams into at least 1nf, 2nf and 3nf Give explanations...

A: Hi due to lack of adequate information we are unable to provide any solution. Please provide us more...

question_answer

Q: Write a program to decipher a numeric code in C++. After years of searching, your team has uncovered...

A: Program Instructions:Add header file and the required comments.Declare variables original_number and...

question_answer

Q: Create a program that will input the 3 game scores of a player and then output the level of the play...

A: Since there are no messages given in the question for the condition where the weighted average falls...

question_answer

Q: Consider the following grammar in BNF (start symbol is ) Which of the following sentences are in the...

A: Backus-Naur Form (BNF):BNF is a formal mathematical method to define the syntax of the programming l...

question_answer

Q: What language is accepted by the Turing machine whose transition graph is in the figure below?

A: Turing machine:Turing machine is a model of a hypothetical computing machine which can use a predefi...

question_answer

Q: How become a ggod programmer?

A: Good programmer:Becoming programmer is not a big thing; it is all about learning the logics of the p...

question_answer

Q: The following print code is to find out the ASCII code, character for the decimal codes,and comparis...

A: The algorithm would involve converting the input integer to character using casting operator as show...