Answer:
- public class FindDuplicate{
-
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
-
- int n = 5;
- int arr[] = new int[n];
-
- for(int i=0; i < arr.length; i++){
- int inputNum = input.nextInt();
- if(inputNum >=1 && inputNum <=n) {
- arr[i] = inputNum;
- }
- }
-
- for(int j =0; j < arr.length; j++){
- for(int k = 0; k < arr.length; k++){
- if(j == k){
- continue;
- }else{
- if(arr[j] == arr[k]){
- System.out.println("True");
- return;
- }
- }
- }
- }
- System.out.println("False");
- }
- }
Explanation:
Firstly, create a Scanner object to get user input (Line 4).
Next, create an array with n-size (Line 7) and then create a for-loop to get user repeatedly enter an integer and assign the input value to the array (Line 9 - 14).
Next, create a double layer for-loop to check the each element in the array against the other elements to see if there is any duplication detected and display "True" (Line 21 - 22). If duplication is found the program will display True and terminate the whole program using return (Line 23). The condition set in Line 18 is to ensure the comparison is not between the same element.
If all the elements in the array are unique the if block (Line 21 - 23) won't run and it will proceed to Line 28 to display message "False".
email because with chat it might wake up the kids and wbsite doesnt make sense. neither does blog so with email you can give personal messages and pictures.
Answer:
Graduated Drivers License process
Explanation:
It gradually develops skills, just using logic. Hope it helped!
Answer:
//class Name
class Name {
// attributes gave you 3
String first_name;
String last_name;
int length = 0;
//constructor with 2 parameters
Name(String first_name, String last_name){
}
//methods
public String find_printed_name(){
return first_name + " " + last_name;
}
public void find_sortable_name(){
return last_name + ", " first_name.charAt(0);
}
public static void main(String[] args){
// instantiate the class
Name test_name = new Name("David", "Joyner");
System.out.println(test_name.first_name);
System.out.println(test_name.last_name);
System.out.println(test_name.find_printed_name());
System.out.println(test_name.find_sortable_name());
}
Explanation:
You didn't specify a language so I did it in Java.
You should know how to declare methods in Python.