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]
2 years ago
15

In JAVA, answer the following:

Computers and Technology
1 answer:
erica [24]2 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
How to connect a three way switch to a regilar switch?
victus00 [196]
The correction is *regular.
4 0
3 years ago
Choices.
Svet_ta [14]

Answer:

1. B

2. D

3. C

4. A

5. B

Explanation:

1. To check the integrity of your hard disk and fix various file system errors, the Windows utility which should be implemented is Check disk (Chkdsk). This utility is always used with the command line interface (CLI) with the command "chkdsk."

2. An event or action took place and it caused damage to data, hardware, software and processing capability of the computer. From the statement given, security risks are being described. Any event or action that is capable of causing a problem to a computer system is considered to be a security risk and should be prevented through the use of an appropriate utility software.

3. Virus is a software program that can infect, damage and disrupts the whole computer system.

4. To protect the whole computer system, the software utility which is needed is an Anti-virus.

5. To avoid losing valuable data to your computer, the most important thing to do is to regularly back-up your files.

7 0
2 years ago
With landscape photography, which depth of field do you normally want? A) Small B)Small to Medium C)Large D)With landscapes it d
RideAnS [48]
I am not 100% on this but i think you would want a Large depth of field. 
3 0
3 years ago
Read 2 more answers
The CEO, calls you into her office and tells you that she's learned that the company needs a database to keep track of supplier
k0ka [10]
The database has been a very unique way to park in
7 0
2 years ago
What is a spreadsheet​
Delicious77 [7]
A spreadsheet function that indicates the average of a group of numbers in a range.
8 0
2 years ago
Other questions:
  • Vpns create a _____________ to transport information through public communications media.
    8·1 answer
  • Describe Mr. Digby, the principal. ​
    10·1 answer
  • Choose the type of critical thinking demonstrated in the example:
    8·2 answers
  • When you use the fill handle to copy a formula to adjacent cells, this creates what kind of cell reference?
    5·1 answer
  • What do developers do to support software products? explain to users which development process model was used to make the produc
    8·1 answer
  • _____________________ denotes the use of human interactions to gain any kind of desired access. Most often, this term involves e
    11·1 answer
  • Why is the most important factor for investors always the quality of the venture's leadership team
    12·1 answer
  • Charlie does not think he will be able to finish his project by the deadline at this point in the decision making progress to so
    13·1 answer
  • Here is the problem specification: An Internet service provider has three different subscription packages for its customers: Pac
    5·1 answer
  • Laptops are used for accessing the internet. Name two advantages and two disadvantages for using a laptop rather than a smartpho
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!