Answer:
import java.util.Scanner;
public class U6_L1_Activity_One{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int[] arr = new int[4];
arr[1] = scan.nextInt();
arr[2] = scan.nextInt();
arr[3] = scan.nextInt();
System.out.println("Contents: " + arr[1] + " " + arr[2] + " " + arr[3]);
int Sum = (1 + 2 + 3);
System.out.println("Sum: " + Sum);
}
}
Explanation:
Answer:
- def show_students(message, sList):
- print(message)
- print(sList)
-
- print("Our students are currently in alphabetical order")
- sList.sort()
- output = ""
- for student in sList:
- output += "-" + student
- print(output)
-
- print("Our students are currently in reverse alphabetical order")
- sList.sort(reverse=True)
- output = ""
- for student in sList:
- output += "-" + student
- print(output)
-
- show_students("Welcome to new semester!", ["Aaron","Bernice", "Cody"])
Explanation:
Firstly we declare a function that will take two inputs, message and student list (Line 1).
In the function, we first print the message and the original input student list (Line 2 - 3). Next, we use sort method to sort the input list and then output the sorted items from the list using a for loop (Line 5-10).
Next, we sort the list again by setting reverse = True and this will sort the list in descending order (Line 13). Again we use the similar way mentioned above to output the sorted items (in descending order) using a for loop (Line 14 -17)
We test the function using a sample student list (Line 18) and we shall get the output:
Welcome to new semester!
['Aaron', 'Bernice', 'Cody']
Our students are currently in alphabetical order
-Aaron-Bernice-Cody
Our students are currently in reverse alphabetical order
-Cody-Bernice-Aaron
Set a buget based on monthly income
It is possible in this example to show that a language can be recognized by a deterministic queue automaton if the language is Turing-recognizable.
For computation, we first need to transfer the input string on queue. We do so by using right moves and pushing each read symbol. Then, we simulate the right move of TM with pull of the rightmost elements of the queue and pushing the new symbol according to transition function back to queue. On the other hand, the left reset of TM is simulated using pushing until we reach special symbol which denotes the left-hand end of tape. We push and pull until we are at the right position. Therefore, we can intuitively simulate left-reset Turing machines.
Yes. They make a lot of money. So eventually after saving your Money, you will make a least 1 million dollars or more.