Must use Array. Must be in JAVA.
Write a program that uses a Scanner object to read in a sequence of integers. The first number in the sequence represents the number of integers in the sequence (i.e., do NOT include the first number as part of the sequence).
Create an array of integers that is the same size as the number of integers. Then the program will read each integer and place it in the array. Print the content of the arrays on one line (each integer separated by a comma).
Details
Input
A sequence of integers, where the first integer represents the number of integers.
Example Input: 5 31 5 18 9 10
Output
Print the array contents with a comma separating the numbers on one line.
Example Output: 31, 5, 18, 9, 10
CODE:
import java.util.*;
public class ReadElement
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
line+=" ";
String w="";
int i=0;
while(line.charAt(i)!=' ')
{
w += line.charAt(i);
i++;
}
int size = Integer.parseInt(w);
int ar[] = new int[size];
for(int k=0;k<size;k++)
{
i+=1;w="";
while(line.charAt(i)!=' ')
{
w+=line.charAt(i);
i++;
}
ar[k] = Integer.parseInt(w);
}
for(int k=0;k<size-1;k++)
System.out.print(ar[k]+",");
System.out.print(ar[size-1]);
}
}
OUTPUT:

Must use Array. Must be in JAVA. Write a program that uses a Scanner object to...
Must be in JAVA. Write a program that uses a Scanner to read in a String. The program will then output a new String with all the vowels (upper and lower case) removed. See output for example output. Details Input A string composed of non-numeric characters Output The input string with the vowels removed Sample input: Welcome to Dalhousie Sample output: Dlhs nvrsty
Write a java program that has a method called sameArrayBackwards. The method takes an array of integers, and checks if the numbers in the array are the same going forward as going backwards and will return a boolean (true or false) depending on the result. You can assume that there is at least one element in the array. Method Header: public static boolean sameArrayBackwards (int [] arr) You will test your method in the main method of your program by...
Write a mips program that defines two integer array that are pre-sorted and the same size (e.g., [3, 7, 9, 11, 15, 21] and [1, 4, 6, 14, 18, 19]) and a function merge that takes the two arrays (and their size) as inputs and populates a single array of twice the size of either input array that contains the elements of both arrays in ascending order. In the example arrays given, then output would be [1, 3, 4, 6,...
Use
c++ as programming language. The file needs to be created ourselves
(ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...
Valentine’s Day Question(JAVA) Suppose you had a list with 30 valentines and you stored their names in an array (you hopeless romantic). Then if you had 5 people ask to be your valentine, you would need to make a new array of size 35 (30 + 5) and copy over the original valentines before being able to add the new valentines to the array. This question uses the same logic. Write a program that has a method called doubleSize. The...
Write a program that reads a sequence of integers into an array and that computes the alternating sum of all elements in the array. For example, if the program is executed with the input data: 2 1 4 9 16 9 7 4 9 11 Then it computes 2 - 1 + 4 - 9 + 16 - 9 + 7 - 4 + 9 – 11 = 4 Use a scanner object to gather the inputs from the user....
( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...
write the solution of the program by python 3 language : I need the program using list : You are given a non-decreasing sequence of n positive integers a1,a2,…,an. Print the number of distinct values in the sequence. For example, if the sequence is 1,2,2,2,3,4,4,5,7,10, the answer is 6 since distinct values are 1,2,3,4,5,7,10. Input The first line contains a positive integer n (1≤n≤1000) — the length of the sequence. The second line contains n space-separated positive integers a1,a2,…,an (1≤ai≤1000)...
Would you please do Pseudocode for this progarm in
Java??
Using scanner algorithm, The scanner takes the name of a
text file from the command line and prints out the list of tokens.
If there is non-valid token in the input file, print out
“error”.
please help me to write Pseudocode!
thank you!!
The scanner takes the name of a text file from the command line. It outputs to the console error if there is any non-valid token in the...
CISC 1115 Assignment 6 Write a complete program, including javadoc comments, to process voter statistics Input to Program: A file containing lines of data, such that each line has 2 integers on it The first integer represents a zip code (in Brooklyn or the Bronx), and the second represents the number of voters in that zip code. Output: All output may be displayed to the screen. In main: 1. Your program will read in all of the data in the...