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
What is a negative impact of digital communication
galina1969 [7]

Answer:

cyber bulling

Explanation:

5 0
3 years ago
What are stored procedures? What kind of attack do stored procedures protect from? Identify two reasons why stored procedures ar
Yuki888 [10]

Answer:

Stored procedures or procedures are subroutines or subprograms in SQL written by the user to accomplish a certain task. it helps to mitigate SQL injection by using markers as placeholders for data input and it streams the query statement and data separately in the database.

Explanation:

The stored procedure used in SQL is a user-defined function. Unlike built-in functions like pi(), they must be called to use them.

SQL injection in query statements is written by hackers to bypass conditions, especially when trying to gain access to other user accounts. Stored procedures use markers or placeholders to prevent this.

4 0
3 years ago
Use the ________ tag to configure a generic area on a web page that is embedded within a paragraph or other block display elemen
Dvinal [7]

Answer:

Use the HTML <p> tag to configure a generic area on a web page that is embedded within a paragraph or other block display element.

Explanation:

Example:

<p> This is some text in a paragraph. </p>

4 0
2 years ago
Advantages and disadvantages of technology
Elina [12.6K]
Technology has a lot of advantages and disadvantages. Few of notable advantages of technology are the fast and easy access to information with the help of internet, the improvised ways of communication like e-mails, and the gadgets or software applications to speed up work. For the disadvantages, the most noticeable effect is the technology related diseases such as the blurring vision caused from the radiation of mobile phones.
6 0
3 years ago
The destructor automatically executes when the class object goes out of ____.
Tema [17]

Answer:

scope    

Explanation:

Destructor is a member function and it call automatically when the class object goes out of scope.

Out of scope means, the program exit, function end etc.

Destructor name must be same as class name and it has no return type.

syntax:

~class_name() { };

For example:

class xyz{

  xyz(){

        print(constructor);

   }

~xyz(){

        print(destructor);

   }

}

int main(){

    xyz num;

   

}//end program

when the object is create the constructor will called and when the program end destructor will call automatically.

4 0
3 years ago
Other questions:
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    15·1 answer
  • Determine encryption that is needed to provide security for the company’s system. This will include plans to address: Passive an
    11·1 answer
  • In this mode, your presentation will fill up the entire screen. Auto Default Standard Window
    6·2 answers
  • Which button, when pressed, allows light from the subject to fall on the sensor?
    8·1 answer
  • How should you set the OHMS ADJust control on a multitester of analog VOM, for resistance measurements?
    12·1 answer
  • What does IDLE stand for
    11·2 answers
  • How do you change your name on brainly after you have made an account​
    5·1 answer
  • How do you change the order of the slides in your presentation in the slide pane 
    15·2 answers
  • Which of the following is not a responsibility of an operating system?
    9·2 answers
  • What is the value of the variable result after these lines of code are executed? &gt;&gt;&gt; a = 5 &gt;&gt;&gt; b = 2 &gt;&gt;&
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!