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
Which one of the following oscilloscope controls is used to move the trace up and down the screen vertically? A. Focus B. Sweep
Andre45 [30]
<span>the trace position is surprise surprise controlled by the position knob!</span>
4 0
3 years ago
What is the current through R1?
patriot [66]
I = V/R. So the answer is 9/200 = 0.045A = 45mA which is B
8 0
3 years ago
Thomas Edison and his assistant W. K. L. Dickson patented which device in 1891
Svetlanka [38]
They patented the kinetoscope
5 0
3 years ago
Read 2 more answers
You plan to use the Fill Down feature on a formula and you need to keep a cell reference the same. Which of the following format
yKpoI14uk [10]
A $E19 I now it because I am in college
6 0
3 years ago
Read 2 more answers
Kelly is working on creating a rocket-focused game in Scratch and is ready to add some sound. What should Kelly do if she wants
Alja [10]

Answer:i think she should add a new sound from the soundtab and use the start sound block to attach her sound to the rocket.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • In addition to training on the products and on company policy, it does not make sense to be prepared to speak about your company
    6·2 answers
  • I have an LG phone. Since I just bought my phone, my bill to text message isn't paid yet. I texted a couple of things playfully
    5·2 answers
  • Please help quickly!!! which of the following is not a peripheral?
    8·2 answers
  • Jason Has A Science Video Project, As He Creats His Project, He Saves, Then Comes Back A Minute Later. The File Is Now Unreadabl
    8·2 answers
  • Yolanda first breaks down the whole game she needs to program into modules. She then breaks these modules into smaller modules u
    11·1 answer
  • The benefit of host and guest operating system difference is:
    8·2 answers
  • Which process could you use to add a table to a document?
    14·1 answer
  • The _____ of a local variable is the function in which the variable is created.
    6·1 answer
  • I need help with Python. The first image is the code and the 2nd is the output.
    8·1 answer
  • Which phrase is the best definition of sparklines in Excel 2016?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!