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
ACL 1 has three statements, in the following order, with address and wildcard mask values as follows: 1.0.0.0 0.255.255.255, 1.1
larisa86 [58]

If a router tried to match a packet sourced from IP address 1.1.1.1 using this ACL, the first statement will be used.

a. First

<u>Explanation:</u>

We use ACL technology to make basic security level in the network.  ACL is strictly used to update the routing in the network and make sure network pears and make sure the flow control for network traffic is followed.

Since it is routing ip address through ACL statement. It all depends on how the network engineer routed the traffic in the network. A packet with source IP address 1.1.1.1 would match any of the three explicitly configured commands described in the question. As a result, the first statement will be used.

The router searches the ACL statement by order and when the match is found it stops execution of the ACL statement that will match with the first occurrence.

7 0
3 years ago
An alternative to increasing the column widths and row heights is to ____ to fit the current width of the column
cupoosta [38]
It seems that you have missed the given options for this statement, but anyway, here is the correct answer. An alternative to increasing the column widths and row heights is to SHRINK THE CHARACTERS IN THE CELL to fit the <span> current width of the column. Hope this answer helps. </span>
4 0
3 years ago
1 MB equals to how many GBs? Or 1 GB = how many MBs? i want to know how many MBs equal a GB, or how many GBs equal a MB; i'm get
Deffense [45]
Approximately 1,000 MBs are in a gigabyte
5 0
3 years ago
Explain the risks to privacy from collecting and storing personal data on computer systems and the programmer’s role to safeguar
Deffense [45]

Answer:

The risks is If your computer is stolen, someone  could get the data and If your laptop messes up you will you lose all the data.

Explanation:

7 0
3 years ago
What is the problem with paying only your minimum credit card balance each month​
Vinvika [58]

Answer:

The problem is that each month your credit card balance increases, and it increase by a certain percent of what you already owe. So if you pay the minimum each month, you'll just end up paying more money because it's ever increasing.

Please give brainliest!

6 0
3 years ago
Read 2 more answers
Other questions:
  • W jakim celu powstawały pieśni żołnierskie i partyzanckie?
    10·1 answer
  • Another important mode, XTS-AES, has been standardized by the __________ Security in Storage Working Group. a. IEEE b. ITIL c. N
    9·2 answers
  • What does core mean? what are they for?​
    5·1 answer
  • Disk ____ is the ability to spread data over multiple disks or volumes
    7·1 answer
  • Juan has performed a search on his inbox and would like to ensure the results only include those items with attachments which co
    14·2 answers
  • Explain program and programming with two examples of each<br>Help​
    12·1 answer
  • _____ provides the best video resolution. *<br><br> VGA<br> HDMI<br> USB<br> DVI
    7·1 answer
  • How to turn off location on iphone without person knowing
    15·1 answer
  • 5. Nadia wants to calculate the total interest, which is the total amount of the payments minus the loan amount. In cell F6, ent
    8·1 answer
  • Does the source MAC address match your PC interface?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!