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
bazaltina [42]
3 years ago
14

Write a method that accepts an integer argument and returns the sum of all the integers from 1 up to (and including) the number

passed as an argument. For example, if 3 is passed as an argument, the method will return the sum of 1+2+3, which is 6. Use recursion to calculate the sum. Test your method in main by prompting the user to enter a positive integer to sum up to. Provide input validation so that only positive values are accepted.
Computers and Technology
1 answer:
kakasveta [241]3 years ago
8 0

Answer:

mark me brainlist

Explanation:

import java.util.*;

public class Main {

       public static int sumOfNumbers(int n)

       {

               if(n==0) return 0;

               else

               return n+sumOfNumbers(n-1);

       }

       public static void main(String[] args) {

               Scanner sc=new Scanner(System.in);

               int n;

               while(true)

               {

                       System.out.println("Enter a number :");

                       n=sc.nextInt();

                       if(n<=0)

                       System.out.println("Enter a positive number ");

                       else

                       break;

               }

               System.out.println("Sum of all numbers upto "+n+" is :"+sumOfNumbers(n));

       }

}

You might be interested in
What is the first step necessary to begin setting up a website once a host has been selected and paid?
NemiM [27]

Answer: Select a domain name

4 0
3 years ago
________ is a technique where the general characteristics are kept and the details are hidden.
valentinak56 [21]

Abstraction is a technique where the general characteristics are kept and the details are hidden.

<h3>What is abstraction?</h3>

Abstraction is the way a person used in  hiding information that are not needed or unwanted.

Note that one can use abstraction when using abstract class and interfaces and as such, Abstraction is a technique where the general characteristics are kept and the details are hidden.

Learn more about abstraction from

brainly.com/question/7994244

#SPJ1

5 0
2 years ago
Negative numbers are encoded using the __________ technique. a. two’s complement b. floating point c. ASCII d. Unicode
OLEGan [10]

Negative numbers are encoded using the two’s complement technique. Two's complement is used to encode negative numbers.

Option  A is correct .

<h3>What method does the in data type use to store negative numbers?</h3>

Most implementations you're likely to encounter store negative signed integers in a form known as two's complement. Another important way of storing negative signed numbers is called one's complement. The one's complement of an N-bit number x is basically defined as x with all bits inverted.

<h3>What is encoding method?</h3>

An encoding technique is the application of established industry conventions to a coded character set to create a coded character scheme. Such rules determine the number of bits required to store the numeric representation of a given character and its code position in the encoding.

Learn more about two complement technique encoding :

brainly.com/question/26668609

#SPJ4

5 0
1 year ago
A(n) ________ is a text or image that allows the user to access that file or web page with a single click.
son4ous [18]
It would be called a link. Connection might work as well. 
5 0
3 years ago
Read 2 more answers
During a traceroute, which action does a router perform to the value in the Time To Live (TTL) field?
Sladkaya [172]

Answer:

<em>During a traceroute, the router decreases the Time To Live values of the packet sent from the traceroute by one during routing, discards the packets whose Time To Live values have reached zero, returning the ICMP error message ICMP time exceeded.</em>

Explanation:

Traceroute performs a route tracing function in a network. It is a network diagnostic commands that shows the path followed, and measures the transit delays of packets across an Internet Protocol (IP) network, from the source to the destination, and also reports the IP address of all the routers it pinged along its path. During this process, the traceroute sends packets with Time To Live values that increases steadily from packet to packet; the process is started with Time To Live value of one. <em>At the routers, the Time To Live values of the packets is gradually decreased by one during routing, and the packets whose Time To Live values have reached zero are discarded, returning the ICMP error message ICMP Time Exceeded</em>

7 0
3 years ago
Other questions:
  • What will be the biased exponent of 1,100.1? <br> A:130<br> B:127<br> C:-127<br> D:2^3
    12·2 answers
  • A ____ is any manipulation of data, usually with the goal of producing information.
    9·1 answer
  • The IBM 370 mainframe computer was introduced in 1970. The 370 Model 145 could hold up to 524,288 bytes of data (512 Kbytes). It
    8·1 answer
  • Who could be involved in the murder of Mr Douglas​
    6·2 answers
  • Which of the following statements is FALSE?
    10·2 answers
  • How to change my age on this app
    10·2 answers
  • Let f(w) = 2w^3 - 5. Let z = 2. What is f(z)?​
    6·1 answer
  • A presentation software that is used to organize and present pertinent information using graphics, word processing, outlining, d
    12·1 answer
  • L a s t. i achieve 15 of 15 question on brainly.
    11·1 answer
  • Which term means a cryptography mechanism that hides secret communications within various forms of data?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!