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
klasskru [66]
3 years ago
8

Write a recursive method to form the sum of two positive integers a and b. Test your program by calling it from a main program t

hat reads two integers from the keyboard and users your method to complete and print their sum, along with two numbers.
Computers and Technology
1 answer:
77julia77 [94]3 years ago
5 0

Answer:

see the code snippet below writing in Kotlin Language

Explanation:

fun main(args: Array<String>) {

   sumOfNumbers()

}

fun sumOfNumbers(): Int{

   var firstNum:Int

   var secondNum:Int

   println("Enter the value of first +ve Number")

   firstNum= Integer.valueOf(readLine())

   println("Enter the value of second +ve Number")

   secondNum= Integer.valueOf(readLine())

   var sum:Int= firstNum+secondNum

  println("The sum of $firstNum and $secondNum is $sum")

   return sum

}

You might be interested in
Assume that a function named swapdoubles has been defined and is available for use in this exercise: that function receives two
Nata [24]

Answer:

C++ Code:

void sort3(double &a, double &b, double &c)

{

   if(a > b)

       swapdoubles(a,b);

   if (b > c)

       swapdoubles(b,c);

   if (a > b)

       swapdoubles(a,b);

}

Explanation:

To change the values of a,b,c within the function, we pass the values by reference. Let us assume that number a = 3.14, b = 2.71, c = 3.04. Since a > b, values of a and b will be swapped.Now a = 2.71 and b = 3.14. Similariy, since b > c, they will be swapped. This way, we move the largest number to its correct position in the first two steps. If there are only three numbers, and the largest number is in its correct position, then for the two remaining numbers, we will only need atmost one swap to exchange their positions. hence, we perform a comparison of a > b once again to see if the b is smaller than a. if its not, then all a,b,c are in sorted order.

6 0
3 years ago
30points!!!! Plz answer quickly
stich3 [128]

Answer:

center

Explanation:

that is the focal point

3 0
3 years ago
Read 2 more answers
It keeps saying “something is going wrong oops!” when i click on my brainly notifications what do I do
AveGali [126]

Answer:

check your app permissions it may be blocking them or try resetting the app

4 0
3 years ago
"When analyzing the IDS logs, the system administrator notices connections from outside of the LAN have been sending packets whe
lakkis [162]

This is false negative. To be marked for alert.

<u>Explanation:</u>

The network administrator or network engineer when he or she is analyzing IDS logs and founded the ip address is same on source and destination both in outside side.

So the either TCPIP address has to change to be scanned across the network. Since same IP address is same pinging rate will high and pinging the same workstation or desktop or laptop.

Alert will not generate because both tcpip address same and if pinging is success.  Ids logs generates based true negative, true positive and false positive will not generate any alert.

5 0
4 years ago
What is displayed on the console when running the following program?
uranmaximum [27]

I guess there should be the program code in your question. I presume that the complete version of your question is the following:

What is displayed on the console when running the following program?

public class Test {

 public static void main(String[] args) {

   try {

     System.out.println("Welcome to Java");

     int i = 0;

     int y = 2 / i;

     System.out.println("Welcome to HTML");

   }

   finally {

     System.out.println("The finally clause is executed");

   }

 }

}

A.  Welcome to Java, then an error message.

B.  Welcome to Java followed by The finally clause is executed in the next line, then an error message.

C.  The program displays three lines: Welcome to Java, Welcome to HTML, The finally clause is executed, then an error message.

D.  None of the above.

Answer to the complete question with explanation:

B.     Welcome to Java followed by The finally clause is executed in the next line, then an error message

After entering <em>try/catch</em> block program will output <em>"Welcome to Java"</em>.

Then <em>ArithmeticException</em> will be raised at line:

<em>int y = 2 / i;</em>

The reason is division by <em>0</em> because <em>i = 0</em>.

After that <em>finally</em> clause will be executed despite exception thrown which will output <em>"The finally clause is executed"</em>.

There could be a chance that you have modified answers to your question. In that case:

Answer to the original question:

a. Welcome to Java,

c. The finally clause is executed, then an error message.

7 0
3 years ago
Other questions:
  • What is information reach? A. A global public network of computer networks that pass information from one to another using commo
    5·1 answer
  • How does titanium usually form or appear in nature?
    15·1 answer
  • Assuming that data mining approaches are to be used in the following cases, identify whether the task required is supervised or
    12·1 answer
  • Which of the following does not illustrate the survey method of choosing a speech topic?
    6·2 answers
  • A new systems development project is Pete’s first experience as a project manager, and he has led his team successfully to the p
    13·1 answer
  • What is ana absolute adress
    11·1 answer
  • Which of the following is a common sense safety procedure that can help prevent electrical accidents?
    15·1 answer
  • FREE BRAINLIEST!!!
    14·2 answers
  • Why is internet download speed slower on a computer vs phone
    5·1 answer
  • What mechanism can organizations use to prevent accidental changes by authorized users?.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!