Question
Asked Jun 4, 2019
3 views

In Eclipse write a while loop which prints the even numbers from 20 to 30 (including 30). 

check_circle

Expert Answer

Step 1

Program Instructions:

  • Create a class named PrintEven, and initialize a variable i to 20 in the main method.
  • Make the exit condition of the while loop to i<=30.
  • Check whether the variable i is divisible by 2 or not.
  • If the number is divisible, it is even. Print the value of the variable i and increment the i.
Step 2

Program:

public class PrintEven {

     public static void main (String[] args) {

          int i = 20;

          while(i<=30){

              if(i%2==0)

  &nb...

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
Show more Q&A
add
question_answer

Q: Create a PL/SQL block to calculate factorial of a number entered from the screen by the user. If the...

A: The PL/SQL block to calculate factorial of a number entered from the screen by the user is given bel...

question_answer

Q: write a program to enter two sides a and b of a right triangle from keyboard calculate its area and ...

A: Given below is the C++ program to enter the two sides of a right triangle and then calculate its are...

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: I am trying ro create this java program , i have the table in my tatabase . I am using postgresql ii...

A: Program Instructions:Add the postgresql jar file in your project library.Create a database and a tab...

question_answer

Q: 2. What happens when you give the following commands if the file named done already exists?$ cp to_d...

A: The given two commands cp and mv are used in Linux and Unix. These commands are used for copying and...

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: function myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x)) wh...

A: Click to see the answer

question_answer

Q: Write a program in Eclipse that prompts the user to enter a string and displays the number of vowels...

A: Solution:Given data, The java code gets the input string from user and display the number of vowels ...

question_answer

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

A: We will have two check the below conditions:-1) class roster is not empty2) the class is one or thre...