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
Isa wants to find out if his co-worker Alexis is available for an event on Wednesday, February 10th. Which calendar
Elena-2011 [213]
Appoint view
Hope this helps
7 0
3 years ago
A reaction between an acid and a base is both a neutralization reaction and what other kind of reaction?
astraxan [27]
Hi!

The answer is C. Double replacement.

Have a nice day!
7 0
4 years ago
In the context of the database design process, the conceptual design step that determines end-user views, outputs, and transacti
faust18 [17]
GUI (graphical user interface)
6 0
3 years ago
I need help. People who know computer science. I have selected a word from the first 1000 words in my dictionary. Using the bina
Rudiy27

Answer:

14

Explanation:

8 0
3 years ago
What is a current trend in ERP systems?
andre [41]

Answer:

C

Explanation:

The top trends to for in your ERP system include: Cloud Deployment, it is cloud adoption will continue to rise and become generally accepted with the most ERP systems.It is reduced costs in capital expenditures and ITcompany resources, then improved maintenance and flexibility, as well as improved the security.

5 0
3 years ago
Other questions:
  • What is the difference between a fragment shader and vertex shader? How do they relate?
    8·1 answer
  • which kind of device does a computer need in order to provide information to a person or something else
    7·1 answer
  • HELP URGENT
    12·2 answers
  • What are the data types in access​
    6·1 answer
  • Is downloading like installing?
    13·1 answer
  • The Internet may best be compared to a/an
    11·1 answer
  • As part of a team, you are assigned to create a financial report. One of your tasks is to put the pieces together as other team
    5·1 answer
  • Which of the following activities are performed by computer programmers? Choose all that apply.
    5·1 answer
  • Which factor is NOT used to determine who can be let go during a downsizing?
    8·2 answers
  • What do people in the movie e.t think about the character E.T
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!