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
Does any body like animal jam
cricket20 [7]

Answer:

Never used it so I do not know.

Explanation:

To be honest i thought you meant like animal jelly at first

7 0
4 years ago
Read 2 more answers
Write a function named remove_duplicates that takes a list (of numeric and/or string values) and returns a new list with only th
Lorico [155]

Answer:

def remove_duplicates(lst):

   no_duplicate = []

   dup = []

   for x in lst:

       if x not in no_duplicate:

           no_duplicate.append(x)

       else:

           dup.append(x)

   for y in dup:

       if y in no_duplicate:

           no_duplicate.remove(y)

   return no_duplicate

Explanation:

Create a function called remove_duplicates that takes one parameter, lst

Create two lists one for no duplicate elements and one for duplicate elements

Create for loop that iterates through the lst. If an element is reached for first time, put it to the no_duplicate. If it is reached more than once, put it to the dup.

When the first loop is done, create another for loop that iterates through the dup. If one element in no_duplicate is in the dup, that means it is a duplicate, remove that element from the no_duplicate.

When the second loop is done, return the no_duplicate

6 0
3 years ago
Which of the following restricts the ability for individuals to reveal information present in some part of the database?
Anni [7]

Answer:

it would have to be flow control which would be C.

Explanation:

8 0
3 years ago
Even though the Certified Information Systems Security Professional (CISSP) certification is not geared toward the technical IT
nirvana33 [79]

Answer:

True

Explanation:

Even though the Certified Information Systems Security Professional (CISSP) certification is not geared toward the technical IT professional, it has become one of the standards for many security professionals is a true statement.

7 0
3 years ago
Write an interactive program to calculate the volume and surface area of a three-dimensional object
Sveta_85 [38]

Answer in Python:

<em># Define program constants</em>

PI = 3.14

<em># Welcome the user to our program</em>

print("### Welcome to the Sphere Volume Calculator")

<em># Ask for the Radius (r) input and store it as a float</em>

radius = float(input("Type the Radius of your sphere in meters: "))

<em># Calculate the volume</em>

volume = 4 / 3 * PI * radius ** 3

<em># Print the result</em>

print("Your sphere volume is:", volume, "m³")

References:

  • https://www.w3schools.com/python/python_variables.asp
  • https://www.w3schools.com/python/python_casting.asp
  • https://www.w3schools.com/python/python_user_input.asp
  • https://www.w3schools.com/python/python_operators.asp
  • https://www.w3schools.com/python/ref_func_print.asp
5 0
3 years ago
Other questions:
  • How can i put this sign in my keybord?<br><br> :::::<br> ^<br> Here is the sign
    8·1 answer
  • Mass production usually uses an _______________ ____________ or production line technique.
    7·1 answer
  • To put out a minor engine fire, use
    12·1 answer
  • Basic engine operation can be divided into four stages. These stages are
    13·1 answer
  • Witch of the following is a malicious program that can replicate and spread from computer to computer?
    13·1 answer
  • What feature of virtualization software allows you to revert to a previous point in time in the event you make an unrecoverable
    9·1 answer
  • The Internet raises the bargaining power of customers most effectively by: making information available to everyone. reducing ba
    15·1 answer
  • Explain the importance of determinism in an industrial LAN
    8·1 answer
  • What memory stores instructions that tell the computer how to start up?
    10·1 answer
  • Television, the internet, and smartphones are different communication _______blank hsn uses in its imc.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!