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
In-s [12.5K]
3 years ago
12

Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 then the outp

ut is: 8 3 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues(int* userVal1, int* userVal2)
Computers and Technology
1 answer:
Ainat [17]3 years ago
4 0

Answer:

public class num3 {

   public static String swapValues(int userVal1, int userVal2){

       int temp = userVal2;

       userVal2 = userVal1;

       userVal1 = temp;

       return(userVal1+", "+userVal2);

   }

   public static void main(String[] args) {

       int val1 = 5;

       int val2 = 8;

       System.out.println("Original values");

       System.out.println(val1+", "+val2);

       System.out.println("Swapped Values");

       System.out.println(swapValues(val1,val2));

   }

}

Explanation:

  • The problem is solved with Java programming language
  • Define the method swapValues() to accept two ints and return a String
  • Within the method body, create a temp variable to hold the value of userVal2 temporary
  • Do the following re-assignment of values userVal2 = userVal1; userVal1 = temp;
  • Return the concatenated String userVal1+", "+userVal2
  • Create two variables and initialize them in the main method
  • Output their values
  • Call swapValues() aand output the swapped values
You might be interested in
PLEASEEEEE HELLPPP IT'S URGENT!!! PLEASEEEEE HELLPPP IT'S URGENT!!!
kogti [31]

Answer:

LED matrix is a grid of lights arranged into rows and columns

A battery is a device consisting of one or more electrochemical cells with external connections for powering electrical devices such as flashlights, mobile phones, and electric cars.

A processor is a machine that processes something.

An accelerometer is a tool that measures proper acceleration.

Universal Serial Bus is an industry standard that establishes specifications for cables and connectors and protocols for connection, communication and power

A compas is an instrument containing a magnetized pointer which shows the direction of magnetic north and bearings from it.

A block editor allows you to add Columns block, which basically adds two columns of paragraph blocks.

Iteration is the repetition of a process in order to generate an outcome.

Selection is the action or fact of carefully choosing someone or something as being the best or most suitable.

Algorithm is a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

debug identifies and remove errors from (computer hardware or software).

an arithmetical value, expressed by a word, symbol, or figure, representing a particular quantity and used in counting and making calculations and for showing order in a series or for identification.

I can do the rest if you want, just wanted to give you a head start :)

8 0
2 years ago
Question 2 Unsaved Which of these is NOT an example of an emerging technology? Question 2 options: Sixth Sense Close Range Drone
alexandr1967 [171]

The answer is <em>B.) Close Range Drones</em>

I just took the test

3 0
3 years ago
Which type of communication protocol converts data into standard formats that can be used by applications?
larisa86 [58]
<span>Arrival protocols are the type of data protocols that convert data into standard formats that can be used by applications, such as email, Web browsers and Skype</span>
8 0
3 years ago
"________ write the instructions for a computer."
Ulleksa [173]
Programmers/Coders write the instructions for a Computer.
4 0
2 years ago
Personal computer is the rise of what?​
gogolik [260]

Answer:

Overuse injuries of the hand.

Obesity.

Muscle and joint problems.

Eyestrain.

Behavioural problems including aggressive behaviour.

6 0
2 years ago
Other questions:
  • You are to create a program using Python that asks the user for a nonnegative number, then computes the mean and variance using
    15·1 answer
  • What are some beginning keyboarding questions?
    10·2 answers
  • Write a code segment that displays the values of the integers x, y, and z on a single line, such that each value is right-justif
    11·1 answer
  • Calculate the cash available to retire debt for each of the six months. There is cash available to retire debt if there is a cas
    8·1 answer
  • The purpose of a malfunction indicator lamp (MIL) is to:
    12·1 answer
  • Unleashes the ability of each person on their team to improve performance, solve problems, and
    6·2 answers
  • which program monitors the computer by looking for known trouble makers as well as suspicious behavior​
    11·1 answer
  • Adding Page Numbers in the Footer
    15·1 answer
  • Please help I will mark brainliest ⚡️⚡️⚡️⚡️
    12·1 answer
  • Write a statement that slices a substring out of the string quote and puts it into a variable named selection. If given the stri
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!