1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
WITCHER [35]
4 years ago
9

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.

Computers and Technology
1 answer:
ivolga24 [154]4 years ago
8 0

Answer:

  1.       public static void rotate4ints(int num1,int num2,int num3,int num4){
  2.        int temp = num1;
  3.        num1 = num4;
  4.        int temp2 =num2;
  5.        num2 = temp;
  6.        int temp3 = num3;
  7.        num3 = temp2;
  8.        num4 = temp3;
  9.        System.out.println("Rotated values "+num1+","+num2+","+num3+","+num4);
  10.    }

Explanation:

This is implemented in Java programming language

Aside the four int variables that will be rotated, three other teporary variables temp1-3 are created to hold temporary values while values are swapped

num1 gets assigned the value of num4, num2 gets assigned the value of num1, num3 gets assigned the value of num2 and num4 gets assigned the of num3.

Pay close attention to the use of the temp variables which are temporary holders of values in-order to swap their values

See a complete java program below with the output attached

<em>public class num8 {</em>

<em>    public static void main(String[] args) {</em>

<em>    int num1 =15; int num2 = 47; int num3 = 6; int num4=23;</em>

<em>        System.out.println("Original Arrangement");</em>

<em>        System.out.println("Rotated values "+num1+","+num2+","+num3+","+num4);</em>

<em>        System.out.println("After Rotation");</em>

<em>        rotate4ints(num1,num2,num3,num4);</em>

<em>    }</em>

<em>    public static void rotate4ints(int num1,int num2,int num3,int num4){</em>

<em>        int temp = num1;</em>

<em>        num1 = num4;</em>

<em>        int temp2 =num2;</em>

<em>        num2 = temp;</em>

<em />

<em>        int temp3 = num3;</em>

<em>        num3 = temp2;</em>

<em>        num4 = temp3;</em>

<em>        System.out.println("Rotated values "+num1+","+num2+","+num3+","+num4);</em>

<em>    }</em>

<em>}</em>

You might be interested in
Which of the following can track your pulse and heart rate, as well as accept calls and display notifications from a smartphone?
alexgriva [62]
The answer is a smart watch most likely the apple or Samsung versions both now offer voice calls and health tracking sensors on the bottom side of the watch most popular is the apple as the company grows more everyday
8 0
3 years ago
So if brainly teaches me better why do we even have real life teachers??????
Katarina [22]

Answer:

i dont know maybe becuse the l.a.w says so?

Explanation:

7 0
3 years ago
This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
Simora [160]

Answer:

// Scanner class is imported to allow program receive user input

import java.util.Scanner;

// class is defined

public class PlayerRoster {

   // main method that begin program execution

  public static void main(String[] args) {

   // Scanner object scan is defined

     Scanner scan = new Scanner(System.in);

   // multi-dimensional array to hold the jersey number and rating

     int[][] players = new int[5][2];

   // boolean flag to keep program alive

     boolean keepAlive = true;

   // the user input is declared as input of type char

     char input;

     

   // for loop that receive 5 player jersey number and ratings

   // it assigns the received input to the already initialized array

     for (int i = 0; i < 5; i++) {

        System.out.println("Enter player " + (i+1) + "'s jersey number: ");

        players[i][0] = scan.nextInt();

        System.out.println("Enter player " + (i+1) + "'s rating: ");

        players[i][1] = scan.nextInt();

        System.out.println();

     }

   // a blank line is printed

     System.out.println();

   // a method is called to display players array

     outputRoster(players, 0);

     

   // while the flag is true

   // display the Menu by calling the outputMenu method

     while (keepAlive) {

        outputMenu();

       // user input is assigned to input

        input = scan.next().charAt(0);

       //  if user input is 'q' then program will quit

        if (input == 'q') {

           keepAlive = false;

           break;

        }

       //  else if input is o, then outputRoaster is called to display players

        else if (input == 'o') {

           outputRoster(players, 0);

        }

       //  else if input is 'u', then user is allowed to edit a player rating

        else if (input == 'u') {

           System.out.println("Enter a jersey number: ");

           int jerseyNum = scan.nextInt();

           System.out.println("Enter a new rating for the player: ");

           int newRating = scan.nextInt();

           for (int l = 0; l < 5; l++) {

              if (players[l][0] == jerseyNum) {

                 players[l][1] = newRating;

              }

           }

        }

       //  else if input is 'a', user is allowed to add a new rating

        else if (input == 'a') {

           System.out.println("Enter a rating: ");

           int rating = scan.nextInt();

           outputRoster(players, rating);

        }

        // else if input is 'r', user is allowed to replace a player

        else if (input == 'r') {

           System.out.println("Enter a jersey number: ");

           int jerseyNum = scan.nextInt();

           boolean exists = true;

           for (int l = 0; l < 5; l++) {

              if (players[l][0] == jerseyNum) {

                 System.out.println("Enter a new jersey number: ");

                 players[l][0] = scan.nextInt();

                 System.out.println("Enter a rating for the new player: ");

                 players[l][1] = scan.nextInt();

              }

           }

           

        }

     }

     

     return;

  }

 

// this method take two parameters, players and min

// it then returns player with ratings greater than min

  public static void outputRoster(int[][] players, int min) {

     System.out.println(((min>0) ? ("ABOVE " + min) : ("ROSTER")));

     int item = 1;

     for (int[] player : players) {

        if (player[1] > min) {

           System.out.println("Player " + item + " -- Jersey number: " + player[0] + ", Rating: " + player[1]);

        }

        item++;

     }

     System.out.println();

  }

 

// outputMenu method to display the program menu

  public static void outputMenu() {

     System.out.println("MENU");

     System.out.println("u - Update player rating");

     System.out.println("a - Output players above a rating");

     System.out.println("r - Replace player");

     System.out.println("o - Output roster");

     System.out.println("q - Quit\n");

     System.out.println("Choose an option: ");  

  }

}

Explanation:

The program is written in Java and it is well commented.                                          

5 0
3 years ago
what does it mean when the save button on the quick access toolbar changes to a circular set of two arrows?
elixir [45]

When the save button on the quick access toolbar changes to a circular set of two arrows, it means that workbook is saved in the cloud  (It means word is automatically syncing your changes back to OneDrive).

  • The Quick Access Toolbar (QAT) is simply known as small modifiable toolbar. It is often located at the top of the office application window that is, it can be seen next to the Microsoft Office button. It is known to have its own  set of independent commands and render quick access to commands like Save, Undo, Redo, etc.
  • OneDrive is a renown Microsoft cloud service and a type of cloud services that helps individuals to link up oneself to all our files. It allows storage and protection of  files, sharing and get to them any time.

Conclusively, we can say that When the save button on the quick access toolbar changes to a circular set of two arrows, it means that workbook is saved in the cloud  (It means word is automatically syncing your changes back to OneDrive).

Learn more from:

brainly.com/question/17163678

7 0
3 years ago
Your motherboard has sockets for 184-pin dimm ram. which type of ram should you install?
noname [10]

Answer:

DDR

Explanation:

DDR is the only type of RAM that runs on 184 pins, its successor DDR2 was upgraded to run on 240 pins.

Hope this helps!

4 0
3 years ago
Other questions:
  • Why will it take so long to complete the high-speed rail route?
    14·2 answers
  • A(n) _____ of an class is where the services or behaviors of the class is defined. (Points : 6) operation
    6·1 answer
  • If you have a rubric, “your teacher can prove you knew what you were supposed to do.” T/F
    10·2 answers
  • Professional photography is a competitive job field. <br> true <br> false
    12·2 answers
  • You are setting up a desktop computer for an AutoCAD specialist who needs a minimum of 125GB of RAM. Which operating system belo
    6·1 answer
  • Write a script that calculates the common factors between 8 and 24. To find a common factor, you can use the modulo operator (%)
    14·1 answer
  • How Do I Make A Walk animation for a school Project?? Gifs?
    13·1 answer
  • Which of the following is a hardware component used to hold the BitLocker encryption key and ensures encrypted data is not acces
    5·1 answer
  • Marco had a database that showed the first, second, and third favorite ice cream flavors for each person in his school. He used
    11·2 answers
  • Write the line of code to calculate the area of a circle with radius 3 and store it in a variable called
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!