Most basic examples of recursion, and most of the examples presented here, demonstrate direct recursion, in which a function calls itself. Indirect recursion occurs when a function is called not by itself but by another function that it called (either directly or indirectly). For example, if f calls f, that is direct recursion, but if f calls g which calls f, then that is indirect recursion of f. Chains of three or more functions are possible; for example, function 1 calls function 2, function 2 calls function 3, and function 3 calls function 1 again.
Indirect recursion is also called mutual recursion, which is a more symmetric term, though this is simply a difference of emphasis, not a different notion. That is, if f calls g and then g calls f, which in turn calls g again, from the point of view of f alone, f is indirectly recursing, while from the point of view of g alone, it is indirectly recursing, while from the point of view of both, f and g are mutually recursing on each other. Similarly a set of three or more functions that call each other can be called a set of mutually recursive functions.
Answer:
Solution part of the question:
if(userTickets>5) //compare the value of userTickets with 5.
awardPoints = 10; // assign the 10 value to the award point
else
awardPoints=userTickets;// assign the userticket value to the awardpoint.
Output:
For the input 4 the output is 4.
For the input 5 the output is 5.
For the input 6 the output is 10.
For the input 7 the output is 10.
Explanation:
All the other part of the program is given on the question so here only if-else statement is given on the answer part. Which is pasted at the place of "/* Your solution goes here */" and the user can get the right answer.
- In the "if" statement the value of "userTickets" variable is get compared by 5 and if it is greater than 5 than variable "awardpoint" assigns the '10' value.
- Otherwise, with the help of "else" statement "userticket" variables value (which is the input value for the program) assign to the "awardpoint" variable.
#let the user input data
Hours = int(input(“enter how many hours were worked”))
Pay_rate = float(input(“Enter the pay rate”))
Pay_amount = Pay_rate * Hours
#calculate the wages
Print (Pay_amount)
#print the final answer
Answer:
Explanation:
The following code is written in Java. It creates the class OrthokonBoard which holds a 4x4 grid board in which each space is an "x" . Once the user creates an OrthokonBoard object they need to pass the positions of player 1 and 2 as an integer array of an x and y coordinate on the grid. Then the constructor of the object places the players on the board. A test version of the class was added to the main method and the output can be seen in the attached picture below.
class Brainly {
public static void main(String[] args) {
int[] player1Pos = {1, 1};
int[] player2Pos = {3,3};
OrthokonBoard newBoard = new OrthokonBoard(player1Pos, player2Pos);
for (char[] x : newBoard.board) {
System.out.println("");
for ( char y : x) {
System.out.print(y + " ");
}
}
}
}
class OrthokonBoard {
char[][] board = {{'x', 'x', 'x', 'x'}, {'x', 'x', 'x', 'x'}, {'x', 'x', 'x', 'x'}, {'x', 'x', 'x', 'x'}};
public OrthokonBoard(int[] playerOnePos, int[] playerTwoPos) {
board[playerOnePos[0]][playerOnePos[1]] = '1';
board[playerTwoPos[0]][playerTwoPos[1]] = '2';
}
}