Write a program in Java.
Ask the user how many integers that he/she wants to enter. Using a for loop, ask the user for that many integers. Then, display all those integers.
view required output
| Standard Input |
|---|
20ENTER 500ENTER 400ENTER 300ENTER 550ENTER 600ENTER 700ENTER -3ENTER 0ENTER 50ENTER 60ENTER 40ENTER 13ENTER 14ENTER 80ENTER 90ENTER 100ENTER 777ENTER 1024ENTER 20ENTER 22 |
How many integers do you have? (Max 20)\n Enter element for subscript 0\n Enter element for subscript 1\n Enter element for subscript 2\n Enter element for subscript 3\n Enter element for subscript 4\n Enter element for subscript 5\n Enter element for subscript 6\n Enter element for subscript 7\n Enter element for subscript 8\n Enter element for subscript 9\n Enter element for subscript 10\n Enter element for subscript 11\n Enter element for subscript 12\n Enter element for subscript 13\n Enter element for subscript 14\n Enter element for subscript 15\n Enter element for subscript 16\n Enter element for subscript 17\n Enter element for subscript 18\n Enter element for subscript 19\n Here are all of those numbers\n 500\n 400\n 300\n 550\n 600\n 700\n -3\n 0\n 50\n 60\n 40\n 13\n 14\n 80\n 90\n 100\n 777\n 1024\n 20\n 22\n
Test Case 2
| Standard Input |
|---|
1ENTER -54 |
How many integers do you have? (Max 20)\n Enter element for subscript 0\n Here are all of those numbers\n -54\n
Test Case 3
| Standard Input |
|---|
9ENTER 9ENTER 8ENTER 7ENTER 6ENTER 7ENTER 8ENTER 2ENTER 3ENTER 4 |
How many integers do you have? (Max 20)\n Enter element for subscript 0\n Enter element for subscript 1\n Enter element for subscript 2\n Enter element for subscript 3\n Enter element for subscript 4\n Enter element for subscript 5\n Enter element for subscript 6\n Enter element for subscript 7\n Enter element for subscript 8\n Here are all of those numbers\n 9\n 8\n 7\n 6\n 7\n 8\n 2\n 3\n 4\n
Test Case 4
| Standard Input |
|---|
3ENTER 100ENTER 200ENTER 300 |
How many integers do you have? (Max 20)\n Enter element for subscript 0\n Enter element for subscript 1\n Enter element for subscript 2\n Here are all of those numbers\n 100\n 200\n 300\n
import java.util.Scanner;
public class ReadOutputArray {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("How many integers do you have? (Max 20)");
int[] arr = new int[in.nextInt()];
for (int i = 0; i < arr.length; i++) {
System.out.println("Enter element for subscript " + i);
arr[i] = in.nextInt();
}
System.out.println("Here are all of those numbers");
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}

Write a program in Java. Ask the user how many integers that he/she wants to enter....
Write a program that asks the user how many integers they would like to enter. You can assume they will enter an integer >= 1. The program will then prompt the user to enter that many integers. After all the numbers have been entered, the program should display the largest and smallest of those numbers (no, you cannot use lists, or any other material we haven't covered). When you run your program it should match the following format: How many...
Java Question where in chapter 7 Arrays. Ive done the code but im still having trouble with the inequality Here my code import java.util.Scanner; public class PS10_5 { public static void main(String args[]) { int[] mynum = new int[5]; int count = 0; int[] lottery = {8,13,27,53,54}; Scanner keyboard = new Scanner(System.in); System.out.println("Check your lottery numbers here!"); for(int subscript=0; subscript<5; subscript++) { System.out.println("Enter number " + (subscript +1) + ":"); mynum[subscript] = keyboard.nextInt(); } for(int subscript=0; subscript<5; subscript++) { for...
In Java chapter 7 Arrays. Ask the user for five names. Output those names. Put an integer before each name to indicate the ordering Here are the required output Test Case 1 Standard Input BillENTER SteveENTER MarkENTER ElonENTER Henry Enter five names\n Enter friend 1\n Enter friend 2\n Enter friend 3\n Enter friend 4\n Enter friend 5\n Here are all of those names\n Friend 1 is Bill\n Friend 2 is Steve\n Friend 3 is Mark\n Friend 4 is Elon\n...
For Java - Write a program that creates an array of 10 integers. Ask the user to enter the subscript (index) of an element, then displays the element located at that subscript. If the subscript entered is out of bounds (less than 0 or greater than length - 1), display the message "Out of Bounds".
JAVA Ask the user for integers. If the user did not enter an integer, ask again. (Type Safe Input) Keep a running total of the intergers entered (sum). Once the user enters 0, stop looping. Print the sum of all the numbers. Do not use try-catch. EXAMPLE OUTPUT: Enter an integer, 0 to stop> [fasdfsa] Invalid input. Enter an integer, 0 to stop> [231.342] Invalid input. Enter an integer, 0 to stop> [1] Enter an integer, 0 to stop> [2]...
Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...
Java programming 1. Write a program that reads an unspecified number of integers, determines how many positive and negative value have been read, and computes the total and average of the input values (not counting zeros. Your program ends with the input 0. Display the average as a floating point number Here are sample runs: (red indicates a user input) Enter an integer, the input ends if it is 0: 1 2 -1 3 0 The number of positives is...
Please write a Java program that ask the user how many beers he or she expects to consume each day, on average, as well as the average amount of money he or she spends on a single 12-ounce can of beer. Studies have shown that, on average, someone who consumes a single 12-ounce can of beer every day without compensating for the calorie intake through diet modifications or extra exercise, will gain approximately 15 pounds in one year. You can...