Matrix Rotations
You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.
Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.
Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.
After the update, all the previous rotation operations have to be applied to the updated initial matrix.
Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.
Input
The first line contains a single integer N.
Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).
Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).
-1 will represent the end of input.
Output
For each Query operation print the element present at row index K and colum index L of the matrix in its current state.
Explanation
For Input:
2
1 2
3 4
R 90
Q 0 0
Q 0 1
R 90
Q 0 0
U 0 0 6
Q 1 1
-1
Initial Matrix
1 2
3 4
For R 90, clockwise rotation by 90 degrees, the matrix will become
3 1
4 2
For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3.
For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1.
Again for R 90, clockwise rotation by 90 degrees, the matrix will become
4 3
2 1
For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4.
For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,
6 2
3 4
After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).
After rotation the matrix will now become
4 3
2 6
Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6.
output
3
1
4
6
Sample Input 1
2
1 2
3 4
R 90
Q 0 0
Q 0 1
R 90
Q 0 0
U 0 0 6
Q 1 1
-1
Sample Output 1
3
1
4
6
Sample Input 2
2
5 6
7 8
R 90
Q 0 1
R 270
Q 1 1
R 180
U 0 0 4
Q 0 0
-1
Sample Output 2
5
8
8
i want exact sample outputs sir
A parking garage charges a $2.00 minimum fee to park for up to three hours. The
garage charges an additional $0.50 per hour for each hour or part thereof in excess of
three hours. The maximum charge for any given 24-hour period is $10.00. Assume that
no car parks for longer than 24 hours at a time. Write a script that calculates and
displays the parking charges for each customer who parked a car in this garage
yesterday. You should input from the user the hours parked for each customer. The
program should display the charge for the current customer and should calculate and
display the running total of yesterday's receipts. The program should use the function
calculate-Charges to determine the charge for each customer. Use a prompt dialog to
obtain the input from the user.
Use a canvas of any reasonable size. Across the top of the canvas are 3 stationary lightbulbs (circles).
• If a lightbulb is currently turned on, it should be colored yellow. If it’s currently turned on, it should be colored black. When your program first starts, have 1 bulb on and the other 2 off.
• When the user clicks a lightbulb: Turn that lightbulb on (if it was off) or off (if it was on).
• The background color should depend on how many lightbulbs are currently turned on. If all of them are on, it should be white. If all of them are off, it should be black. If one of them is on, it should be dark grey. If two of them are on, it should be light grey
Code needed in processing format please
State whether each of the following is true or false. If false, explain why.
a). An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute.
b). A set of statements contained within a pair of parentheses is called a block.
c). A selection statement specifies that an action is to be repeated while some condition remains true.
d). A nested control statement appears in the body of another control statement.
e). Java provides the arithmetic compound assignment operators +=, -=, *=, /= and %= for abbreviating assignment expressions.
f). The primitive types (boolean, char, byte, short, int, long, float and double) are portable across only Windows platforms.
g).Specifying the order in which statements (actions) execute in a program is called program control.
h). The unary cast operator (double) creates a temporary integer copy of its operand.
i). Instance variables of type boolean are given the value TRue by default.
j).Pseudocode helps a programmer think out a program before attempting to write it in a programming language.
Write four different Java statements that each add 1 to integer variable x.
1.How do you understand the term Language “Processing System”
2. How does a program using a C++ compiler be executed on a host machine?
CreateCreate a point class which can specify a point in a two dimensional plane. It should have a no-
arg constructor, which initialize the co-ordinates by 0 and also have a two-arg constructor,
which initialize the co-ordinates by the appropriate two parameters. It should also have a show(
) function, which will display the values of the two co-ordinates. Now find the distance between
two objects of the point class and show its use in the main( ) function.
[The distance between (x1,y1) to (x2,y2) points is d = √((x2-x1)²+(y2-y1)²) ]
State whether each of the following is true or false. Explain why.
a. The default case is required in the switch selection statement.
b. The break statement is required in the last case of a switch selection statement.
c. The expression ( (x > y) && (a < b ) ) is true if either x > y is true or a < b is true .
d. An expression containing the || operator is true if either or both of its operands are true.
e. The comma (,) formatting flag in a format specifier (e.g., %,20.2f) indicates that a value should be output with a thousands separator.
f. To test for a range of values in a switch statement, use a hyphen () between the start and end values of the range in a case label.
g. Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.
State whether each of the following is true or false. If false, explain why.
a). An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute.
b). A set of statements contained within a pair of parentheses is called a block.
c). A selection statement specifies that an action is to be repeated while some condition remains true.
d). A nested control statement appears in the body of another control statement.
e). Java provides the arithmetic compound assignment operators +=, -=, *=, /= and %= for abbreviating assignment expressions.
f). The primitive types (boolean, char, byte, short, int, long, float and double) are portable across only Windows platforms.
g).Specifying the order in which statements (actions) execute in a program is called program control.
h). The unary cast operator (double) creates a temporary integer copy of its operand.
i). Instance variables of type boolean are given the value TRue by default.
j).Pseudocode helps a programmer think out a program before attempting to write it in a programming language.
Write four different Java statements that each add 1 to integer variable x.
Why is method main declared static
Given a MxN matrix,write a program to print all Anti-Diagonals elements of matrix
Input
The first line of input will contain a M, N values separated by space.
The second line will contain matrix A of dimensions MxN.
Output
The output should contain anti-diagonal elements separated by a line.
Explanation
For example, if M = 4, N = 4
Matrix A:
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
So the output should be
1
2 5
3 6 9
4 7 10 13
8 11 14
12 15
16
Sample Input 1
2 3
1 5 5
2 7 8
Sample Output 1
1
5 2
5 7
8
Sample Input 2
3 4
1 2 3 4
5 6 7 8
9 10 11 12
Sample Output 2
1
2 5
3 6 9
4 7 10
8 11
12