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
swat32
3 years ago
5

Create an array of that size and then prompt the user for numbers to fill each position in the array. When all of the positions

are filled, display the contents of the array to the user. Below is a sample transcript of what your program should do. Text in bold is expected input from the user rather than output from the program.Please enter the number of digits to be stored: 5Enter integer 0: -1Enter integer 1: 10Enter integer 2: 15Enter integer 3: -6Enter integer 4: 3The contents of your array:Number of digits in array: 5Digits in array: -1 10 15 -6 3
Computers and Technology
1 answer:
andreyandreev [35.5K]3 years ago
4 0

Answer:

In Java

import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

     Scanner input = new Scanner(System.in);

     int arrsize;

     System.out.print("Please enter the number of digits to be stored: ");

     arrsize = input.nextInt();

     int[] myarr = new int[arrsize];

     for (int kount = 0; kount < arrsize; kount++) {

        System.out.print("Enter integer: ");

        myarr[kount] = input.nextInt();      }

     System.out.println("The contents of your array:\nNumber of digits in array: "+arrsize);

     System.out.print("Digits in array: ");

     for (int kount = 0; kount < arrsize; kount++) {

        System.out.print(myarr[kount]+" ");      }

  }

}

Explanation:

This declares the length of the array

     int arrsize;

This prompts the user for the array length

     System.out.print("Please enter the number of digits to be stored: ");

This gets the input for array length

     arrsize = input.nextInt();

This declares the array

     int[] myarr = new int[arrsize];

The following iteration gets input for the array elements

<em>      for (int kount = 0; kount < arrsize; kount++) { </em>

<em>         System.out.print("Enter integer: "); </em>

<em>         myarr[kount] = input.nextInt();      } </em>

This prints the header and the number of digits

     System.out.println("The contents of your array:\nNumber of digits in array: "+arrsize);

     System.out.print("Digits in array: ");

The following iteration prints the array elements

<em>      for (int kount = 0; kount < arrsize; kount++) { </em>

<em>         System.out.print(myarr[kount]+" ");      }</em>

You might be interested in
During Which model states that communication can occur simultaneously?
SVETLANKA909090 [29]

Answer:

i dont see any models...please include a picture

8 0
3 years ago
Disadvantage do you think one can have if he or she does use electronic media
Dima020 [189]
- discontinuity
- dependence on the electric power
and more
6 0
3 years ago
What is the Slide Sorter View used for?
bonufazy [111]

Answer:

b. bc u can delete and add slides in ur presentation

3 0
3 years ago
Read 2 more answers
Information taken directly from an existing classified source and stated verbatim in a new or different document is an example o
kvv77 [185]

This is known as information extraction.

4 0
3 years ago
Given two integers low and high representing a range, return the sum of the integers in that range. For example, if low is 12 an
Vaselesa [24]

       System.out.println(sumRange(12, 18)); // prints 105

       System.out.println(sumRange(18, 12)); // prints 0

       System.out.println(sumRange(18, 18)); // prints 18

   }

   public static int sumRange(int low, int high)

   {

       int sum = 0;

       for (int val = low; val <= high; val++){

           sum += val;

       }

       return sum;

   }

}

8 0
3 years ago
Other questions:
  • Plane eyes I don't know
    9·1 answer
  • Women make up 52 percent of the voting-age population and are more likely to vote, yet
    12·2 answers
  • PLEASE HELPPPPPPP
    15·1 answer
  • A powerful computer that acts as a hub for other computers is a called a ______.
    15·2 answers
  • Which tag defines the visible content of a web document?
    10·1 answer
  • To activate Spelling and Grammar check using the ribbon, navigate first to the _____ tab
    14·2 answers
  • Which of the following is part of the cycle of dating violence
    8·1 answer
  • What do you use to put information into a computer?
    9·2 answers
  • An organization is conducting a study to see if hazardous waste sites pose health risks for cancer or other conditions, such as
    12·1 answer
  • Although plants and ainamals are both living things___
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!