6) GitHub Link included for the further code review
Topic Nr. 1 (Object-Oriented Programming)
1) How to Conduct While Loop with Break method
2) We imported Util scanner meaning to ask the user to make up a random number for an n integer. And when we develop a loop in which if that n number is not 0 then we print list of question-statements.And we continue taking user input numbers and performing some calculations until the statement BREAK, by which we stop the loop, so that it ends.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
As you can see all the statement we wrote in our code are all the questions that we need to answer once we run the code. So we give computer any number, and then we give a second number, based on that we get a total number, and then it performs a simple multiplication calculation telling us how old we are in the total number of days. When we give number 0, it BREAKS the loops and ends our conversation.
2) I developed a Method where a String statement will serve as an answer and once that answer is called upon, it will print that value which is a String statement, this is how we will pass that value.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
As you can see our two words is our value: little and ladybird, our purpose is to fill in that blank by passing that value to the method. And when we print answer, the answer is that value: little and ladybird. And that's how you pass a value.
2) We will create a method called Sub, and will store list of names of fruits. The name of those all fruits will be dragonfruit. And our numbers will be called an int s. So we will pass these two value inside the method named Sub.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
As you can see the statement is printed saying that our favorite fruit is these fruits, and it prints last four numbers of our social. This is how these two value and integer and a String is stored in a method and passed over to the method.
2) We want to create a value by identifying it as a String and not a number. this string will be returned once we call its method which is x. And in the method we will called an x as 'Adams' so when we print the method and x, we return that value String 'Adams'.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
As you can see the name of our value is Adams. It's represents by the method x. When we call for an x, we return its value 'Adams.' And that is how we create a value, and return it.
1) How to create a new Object in Java and call upon its method?
2) We have created a car example tho showcase how statement are printed in relation to their methods, so we have a new object assigned to a method, and when we call for that method it prints all of its objects.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
You can see how every variable is assigned to the accelerator followed by a number. And for every new object we have s String as a statement, and a variable either an integer or a String. Every variable is identified in the beginning and is assigned to Accelerate method such as 1, 2, 3 and etc. Toyota is our object in the class named Car. And every time we call for that object we will call for class.object followed by the name of the variable. Such as Car.toyota.motion.
and that is how you create an object and a method in a given class, so when you call for that variable, you identify the name of the object, and the name of the variable.
1) How to build a Java Application with an Array and the Two Methods: math.random and math.ceil?
2) We will create a Lottery generating four winning numbers. First we need to create an array which in this application will be a tuple; a group of integers represented by a one variable. And will call upon that variable including the two methods mentioned above. By which we will use these methods to print random four numbers. These numbers will serve as the winning-lottery numbers.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
In all four images you can see how the four numbers are chosen by these two methods: math.ceil and math.random. You can see we have identifies a list of numbers in our array named n. So the four numbers are generated based on the numbers given in the array. However, every time we run the code, it generates another new four random numbers. We have used a loop to identify that if the math.random number is in the list of the array-numbers. Then we print those math.random numbers, if our first number in the array is not 1, then we won't print any random numbers. But in this application our array starts with number 1, meaning that our loop will print four random numbers, because it meets this condition.
1) What is a Recursion in Java and how to create a Reversive-Recursion in the LinkedList?
2) For this topic will create a class in which will declare data and integer will be that data. Will identify the current data as Node current, and the next data as next, and prevent as preventing, but all will have Node object. Will create a While loop meaning the actual order will have a list o items such as list of Zodiac names. Every time will create a next list, meaning will print a new statement recurring after another. And will call upon a head variable by which it will reverse the actual list that we will print the list backwards from the original order.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
Firstly the list will be identified as a Node, as you can see we have Node current, Node previous, node head, Node List. When we list.next that mean the list is printed in order as a current Node. But when we call upon Head.reverse. What it will do is reverse the primary list which is our head list. And that is what we want. First we created a current list, and then called upon head=reverse.list. This is how the list of Zodiacs are printed, followed by a list of statements. And when at first it's all printed in order, but after it's reversed then it's printed in a reversive order.
and this is how you can reverse a linkedlist in Java.