answer.
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
Nookie1986 [14]
2 years ago
12

Write a program whose input is two integers and whose output is the two integers swapped. Place the values in an array, where x

is position 0 and y is position 1. Ex: If the input is: 3 8 then the output is: 8 3 Your program must define and call a method: public static void swapValues(int[] values)
Computers and Technology
1 answer:
Aliun [14]2 years ago
7 0

Answer:

import java.util.Arrays;

public class swap{

   public static void main(String []args){

       int [] arr = {2,4};

       swapValues(arr);

   }

   public static void swapValues(int[] values){

       int temp;

       System.out.println(Arrays.toString(values));

       temp=values[0];

       values[0]=values[1];

       values[1] =temp;

       System.out.println(Arrays.toString(values));

   }

}

Explanation:

In the program above, we created the method swapValues that receives an array of integers as parameters. in the method definition, we created a temp variable that is used to swapp the element at index 0 and index 1. Java's Arrays.to string method is used to print the array before and after the swap.

You might be interested in
Which of the following facts determines how often a nonroot bridge or switch sends an 802.1D STP Hello BPDU message?
irinina [24]

Answer:

b. The Hello timer as configured on the root switch.

Explanation:

There are differrent timers in a switch. The root switch is the only forwarding switch in a network, while non root switches blocks traffic to  prevent looping of BPDUs in the network. Since the root switch is the only forwarding switch, all timing configuration comes from or is based on the configuration in the root.

The hello timer is no exception as the nonroot switch only sends 802.1D DTP hello BPDU messages forwarded to it by the root switch and its frequency depends on the root switch hello timer.

8 0
2 years ago
You develop a cost-cutting measure for your department, and email the idea to your supervisor. Your supervisor forwards your mes
Setler79 [48]

Answer: The members of the department and also the heads of the operations and IT

Explanation:

 According to the question, the secondary audience of our message is the members of the IT department and also the head of the operation in an organization.

The main responsibility of the operational head is to implement and maintain the correct or right processes in an organization. The main function of the head of the operation are as follows:

  • Implementing and improving the performance
  • Formulating the strategy
  • Securing compliance

7 0
1 year ago
Writing in Java, write a program that prompts the user to input an integer and then outputs both the individual digits of the nu
larisa [96]

Answer:

//Here is code in java.

import java.util.*;

class Main

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

       int in;

     //scanner class object to read the input

    Scanner scr=new Scanner(System.in);

     // variable to keep running total

    int total=0;

    System.out.println("please enter an Integer:");

     // read the input first time

    in=scr.nextInt();

    System.out.print("individual digits of "+in+" is ");

    if(in<0)

    {

        in=-(in);

    }

   

 

     //call the function to print the digits of number

   print_dig(in);

   System.out.println();

    //calculate the sum of all digits

   do{

       int r=in%10;

       total=total+r;

       in=in/10;

   }while(in>0);

    //print the sum

   System.out.println("total of digits is: "+total);

     

   }catch(Exception ex){

       return;}

}

 //recursive function to print the digits of number

public static void print_dig(int num)

{  

    if(num==0)

    return;

    else

    {

    print_dig(num/10);

    System.out.print(num%10+" ");

    }

}

}

Explanation:

Read a number with the help of object of scanner class.if the input is negative

then make it positive number before calling the function print_dig().call

the recursive method print_dig() with parameter "num".It will extract the digits

of the number and print then in the order. Then in the main method, calculate

sum of all the digits of number.

Output:

please enter an Integer:                                                                                                  

3456                                                                                                                      

individual digits of 3456 is 3 4 5 6                                                                                      

total of digits is: 18

please enter an Integer:                                                                                                  

-2345                                                                                                                      

individual digits of -2345 is 2 3 4 5                                                                                      

total of digits is: 14

6 0
1 year ago
Assign decoded_tweet with user_tweet, replacing any occurrence of 'TTYL' with 'talk to you later'. Sample output with input: 'Go
nekit [7.7K]

Answer:

I am going to use the Python programming language to answer this. The source code is given below:

print("Enter your tweet here")

user_tweet = input()

decoded_tweet = user_tweet.replace('TTYL', 'talk to you later')

print("This is the decoded tweet: ")

print(decoded_tweet)

Explanation:

In the program the replace() module was used to replace 'TTYL' with 'talk to you later.'

Attached is the screenshot of the output.

8 0
2 years ago
Read 2 more answers
The __________ of a desktop computer is the case that houses the computerâs critical parts, such as the processing and storage d
Phantasy [73]
You said it in your question. The case! Though it's also given other names, such as housing, chassis, enclosure etc.
4 0
1 year ago
Other questions:
  • ____ refers to typing your entire e-mail message or discussion group post using only capital letters.
    15·1 answer
  • A(n) _____ can be used to reveal a competitor’s program code, which can then be used to develop a new program that either duplic
    9·1 answer
  • Someone else can drive your car if _____.
    12·2 answers
  • Address the FIXME comments. Move the respective code from the while-loop to the created function. The add_grade function has alr
    14·1 answer
  • Consider the following relationship involving two entities, students and classes:A student can take many classes. A class can be
    9·1 answer
  • What is the value of x after each of the following statements is encountered in a computer program, if x=1 before the statement
    9·1 answer
  • Q3** Write a query to create a new price list for books written by the same author. Allow the user to enter only the first 4 let
    15·1 answer
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
  • Which of the following Teacher Tips would NOT be helpful when trying to select content from the Chrome Web Store? "Can be used a
    9·1 answer
  • When authenticating a user's password, the password supplied by the user is authenticated by comparing the ____ of the password
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!