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 business names would be rated Incorrect for name accuracy? Answer McDonald's McDonald's H&M McDon
Damm [24]

McDonald's H&M McDonalds Inc is incorrect for name accuracy.

Explanation:

The correct Name is McDonald's. But Mc Donald's H&M and McDonalds inc is incorrect for name accuracy.

McDonald's is a fast-food company based in America. It has its retail outlets throughout the world. It is very famous for its burgers and french fries. It is the world's second-largest employer in the private sector. It is a symbol of globalization as it has its outlets throughout the world.

6 0
3 years ago
While engineers work to create computers that can understand us emotionally, ________ are also evolving toward a more human appe
aleksandrvk [35]
While engineers work to create computers that can understand us emotionally, ________ are also evolving toward a more human appearance.

affecting computing techniques
8 0
2 years ago
Write down a program in SNOBOL thatcalculates the factorial of 7.
Sati [7]

Answer:

         n = f = 7

loop  f = gt(n,1) f * (n = n - 1) :s(loop)

         output =  f

end

Explanation:

3 0
3 years ago
Is a computer network that spans a relatively small area, allowing all computer users to connect with each other to share data a
Natalija [7]
The answer is a Local Area Network
5 0
3 years ago
Which of the following is not a web browser? A. safari B. explorer C. chrome D. google​
Brums [2.3K]

Answer:

D) Google

Explanation:

Google on it's own is a search engine. Safari, Explorer, and Chrome are web browsers.

I hope it helps :)))

7 0
2 years ago
Read 2 more answers
Other questions:
  • Your school computer library has a network that connects computers and devices within a few small rooms. what type of network do
    7·1 answer
  • An ink-jet printer is a type of impact printer. <br> a. True <br> b. False
    8·1 answer
  • Stuart wants to delete some text from a slide. What should Stuart do?
    8·1 answer
  • What are the characteristics of calendar sharing options in Outlook 2016? Check all that apply.
    13·2 answers
  • Consider the following code:
    6·1 answer
  • The address for the website you want to visit is called the browser internet URL World Wide Web
    5·2 answers
  • The landscape layout is more appropriate for leaflet. <br> TRUE OR FALSE
    6·1 answer
  • One rule in the Java programming language is that you have to place a semicolon at the end of each statement. What is this rule
    10·2 answers
  • The type value ____ for the input element may cause modern browsers to validate entries to ensure that they are valid web addres
    14·1 answer
  • Write a program to demonstrate circular linked list with operations using pointers – insert
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!