Question: Project 1 : Java Basic Review ( Print distinct integers ) Write a program, named DistinctValues.java, whose input is an unknown number of integers (
Project : Java Basic Review
Print distinct integers
Write a program, named DistinctValues.java, whose input is an unknown number of integers assume a
maximum of distinct integers is The program stops reading when it encounters a The program then
displays the distinct integers in ascending order and separates them by exactly one space ie if a number
appears multiple times, it is displayed only onceHint: Read an integer and store it in an array of size if it
is new. If the integer is already in the array, ignore it After the input, the array contains the distinct integers.
Sort the array and display the content.
Your program must not assume anything about the number of input values, meaning you can't declare an array
to hold all of them. Instead, you should declare an array of integers. In particular, keep a variable to the next
open slot of the array. Use a Scanner to read an integer. If it is not there is room in the array, and is not
duplicated, write it to that slot and increment the value.
Program criteria:
Must only use array data Structure Do not use any other ADT
Array size must be
The array should not contain any duplicate values.
output should be in ascending order.
Download the file ReverseTextOriginal.java from the Canvas, and open it in jGrasp or a text editor of your
choice This file contains part of a program to reverse the given text. The function main looks like this:
public static void mainString args
String s input.nextLine;
System.out.printreverseTextS;
You need to define a static method called reverseText that receives a String from the keyboard. in the example
below the input is: Data Structures And Algorithms, but I will test your program with different inputs! The
purpose of the function reverseText is to reverse the order of characters in each word within the given input.
Remember the whitespace and initial word order must be preserved. Do not modify the main method. Here is a
screenshot of my program in action
jGRASP exec: java ReverseText Welcome to Java
Data Structures And Algorithms
ataD serutcurtS dnA smhtiroglA
jGRASP: operation complete.Project : Java Basic Review
Print distinct integers
Write a program, named DistinctValues.java, whose input is an unknown number of integers assume a
maximum of distinct integers is The program stops reading when it encounters a The program then
displays the distinct integers in ascending order and separates them by exactly one space ie if a number
appears multiple times, it is displayed only onceHint: Read an integer and store it in an array of size if it
is new. If the integer is already in the array, ignore it After the input, the array contains the distinct integers.
Sort the array and display the content.
Your program must not assume anything about the number of input values, meaning you can't declare an array
to hold all of them. Instead, you should declare an array of integers. In particular, keep a variable to the next
open slot of the array. Use a Scanner to read an integer. If it is not there is room in the array, and is not
duplicated, write it to that slot and increment the value.
Program criteria:
Must only use array data Structure Do not use any other ADT
Array size must be
The array should not contain any duplicate values.
output should be in ascending order.
Download the file ReverseTextOriginal.java from the Canvas, and open it in jGrasp or a text editor of your
choice This file contains part of a program to reverse the given text. The function main looks like this:
public static void mainString args
String s input.nextLine;
System.out.printreverseTextS;
You need to define a static method called reverseText that receives a String from the keyboard. in the example
below the input is: Data Structures And Algorithms, but I will test your program with different inputs! The
purpose of the function reverseText is to reverse the order of characters in each word within the given input.
Remember the whitespace and initial word order must be preserved. Do not modify the main method. Here is a
screenshot of my program in action
jGRASP exec: java ReverseText Welcome to Java
Data Structures And Algorithms
ataD serutcurtS dnA smhtiroglA
jGRASP: operation complete.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
