Write the definition of a function named rotate4ints that is passed four int variables. The function returns nothing but rotates the values of the fourvariables: the first variable, gets the value of the last of the four, the second gets the value of the first, the third the value of the second, and the last(fourth) variable gets the value of the third. So, if i, j, k, and m have (respectively) the values 15, 47, 6 and 23, and the invocation rotate4ints(i,j,k,m) is made, then upon return, the values of i, j, k, and m will be 23, 15, 47 and 6 respectively.

Question
Asked Jan 31, 2019
18 views

Help.

Write the definition of a function named rotate4ints that is passed four int variables. The function returns nothing but rotates the values of the four
variables: the first variable, gets the value of the last of the four, the second gets the value of the first, the third the value of the second, and the last
(fourth) variable gets the value of the third. So, if i, j, k, and m have (respectively) the values 15, 47, 6 and 23, and the invocation rotate4ints
(i,j,k,m) is made, then upon return, the values of i, j, k, and m will be 23, 15, 47 and 6 respectively.
help_outline

Image Transcriptionclose

Write the definition of a function named rotate4ints that is passed four int variables. The function returns nothing but rotates the values of the four variables: the first variable, gets the value of the last of the four, the second gets the value of the first, the third the value of the second, and the last (fourth) variable gets the value of the third. So, if i, j, k, and m have (respectively) the values 15, 47, 6 and 23, and the invocation rotate4ints (i,j,k,m) is made, then upon return, the values of i, j, k, and m will be 23, 15, 47 and 6 respectively.

fullscreen
check_circle

Expert Answer

Step 1

Below is the algorithm:-

start
function rotate4ints(i,j,k,m)
declare integer temp1=i
i=m
declare integer temp2=j
j=temp1
declare integer temp3=k
k=temp2
m=temp3
display "The values after rotation are: "+i+" "+j+" "+k+" "+m
end function
end

Step 2

Below is the java code for the above algorithim:-

public class Rotate{
public void rotate4ints(int i,int j,int k,int m){
int temp1=i; //copy i in temp1
i=m; //copy m in i
int temp2=j; //copy j in temp2
j=temp1; //copy temp1 in j
int temp3=k; //copy k in temp3
k=temp2; //copy temp2 in k
m=temp3; //copy temp3 in m
System.out.println("The values after rotation are: "+i+" "+j+" "+k+" "+m);
}
}

Step 3

Below is the screenshot...

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: I need help with creating a main.css, I already have the HTML.the details are in the pic and I will ...

A: CSS codebody{font-family: Sans-serif;/*set the font to Sans serif*/} a {color: maroon;/*set links to...

question_answer

Q: JAVA PROGRAM NEED TO BE SUBMITTED TOMORROW   you operate 3 hot dog stands distributed throughout tow...

A: The following override methods are created along with @Override annotation:equalsfinalizetoStringThe...

question_answer

Q: Nine coins are placed in a 3x3 matrix with some face up and some face down. You can represent the st...

A: As there is no programming language mentioned, we are writing this program in JAVA. The program is g...

question_answer

Q: Write a java program called Sales considering the following directions and the sample run. Practice ...

A: The program has the following steps:Declare the variablesReceive the input from the userCalculate th...

question_answer

Q: Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-...

A: Hey, since there are multiple questions posted, we will answer first question. If you want any speci...

question_answer

Q: What is notepad ++ or notebad ? How to use it and what for ?It's required for my class The Web Stand...

A: We are explaining here the concept of notepad and notepad ++ and how and for what purpose these are ...

question_answer

Q: Create a program that will input the 3 game scores of a player and then output the level of the play...

A: Since there are no messages given in the question for the condition where the weighted average falls...

question_answer

Q: Is each of the following an absolute pathname, a relative pathname or a simple file name?a. Milk_cob...

A: Absolute path specifies the location of a directory or file from the root directory including a slas...

question_answer

Q: How do you convert 172.16.20.55 to binary format?

A: 172.16.20.55 represents IP address in decimal format. In order to convert it into binary format we n...