1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
abruzzese [7]
3 years ago
15

In JAVA, answer the following:

Computers and Technology
1 answer:
erica [24]3 years ago
7 0

Answer:

The JAVA program is as follows.

import java.util.Scanner;

public class Program

{

   static int n;

public static void main(String[] args) {

    //scanner object

    Scanner stdin = new Scanner(System.in);

    //loop executes till number entered is in the range of 1 to 10

    do

    {

        System.out.print("Enter any number: ");

        n = stdin.nextInt();

    }while(n<1 || n>10);

    System.out.println("Number is valid. Exiting...");

}

}

OUTPUT

Enter any number: 0

Enter any number: 23

Enter any number: 10

Number is valid. Exiting...

Explanation:

The program is explained.

1. The integer variable, n, is declared static since the variable should be accessible inside main() which is static.

2. An object of Scanner, stdin, is created inside main().

3. Inside do-while loop, the user is asked input any value for n.

4. The loop continues till user inputs a number which is not in the given range, beginning from 1 to 10.

5. The loop will not be terminated till the user enters a valid input.

6. Once a valid input is entered, the message is displayed to the console and the program ends.

7. The variable, n, is declared at the class level and is a class variable. Class variables are declared inside the class but outside all the methods in that class.

8. Since JAVA is a purely object-oriented language, all the code is written inside class.

9. The object of class is not created since only one class is included in the program. If more than one class is included, then the object of the class which does not has the main() method will be created inside main().

10. User input for integer is taken via scanner object and using nextInt() method.

11. The methods, print() and println() display the messages to the console. The only difference is that println() inserts a new line after displaying the message.

12. The name of the class having main() and the name of the program should be the same.

You might be interested in
__________ is the electronic transmission of signals for communications, which enables organizations to carry out their processe
Serjik [45]

Telecommunications is the electronic transmission of signals for communications, which enables organizations to carry out their processes and tasks through effective computer networks

4 0
3 years ago
Hi! This is python coding. Please don't take advantage, actually, answer!
Greeley [361]

Answer:

Try and do number = 7

If that does not work then I dont know what to tell you.

Explanation:

8 0
3 years ago
Landing pages in a foreign language should never be rated fully meets?
PilotLPTM [1.2K]

Answer:

if the landing page provides all kind information of information as to that site people usually like it or will most likely enjoy it

BRAINLIEST?????

Explanation:

3 0
2 years ago
Stella likes to work with colors and moving pictures. She is good at drawing. Which job role should she choose
PilotLPTM [1.2K]

Answer:

Digital Art or Animator for moving picture art.

Explanation:

7 0
3 years ago
Read 2 more answers
A shopaholic has to buy a pair of jeans , a pair of shoes l,a skirt and a top with budgeted dollar.Given the quantity of each pr
Rasek [7]

Answer:

hfjgyyitjtjjtjtj*jj*jtjtjthrhrhfhffbf

4 0
3 years ago
Other questions:
  • You have been hired to upgrade a network of 50 computers currently connected to 10 mbps hubs. this long-overdue upgrade is neces
    12·1 answer
  • Which loan type requires you to make loan payments while you’re attending school?
    7·1 answer
  • Briefly explain five measures you have undertaken to protect your confidential
    12·1 answer
  • Which of the following is the best definition of being a “digital citizen”?
    6·2 answers
  • Employees at the Red Bluff Golf Club &amp; Pro Shop have the opportunity to become certified trainers if they log enough hours.
    13·1 answer
  • Which option in Outlook allows a user to look at multiple calendars in a side-by-side fashion?
    14·2 answers
  • A Windows application which demands a lot of raw processing power to execute repetitive complex calculations is a good candidate
    5·1 answer
  • Tree diagrams are useful for
    12·1 answer
  • Why are Quick Parts useful in an Outlook message?
    5·1 answer
  • Why do software managers have to be generalists with a range of skills, rather than simply technical specialists?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!