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]
2 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]2 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
A _____ is a network that uses multiple access points to link a series of devices that speak to each other to form a network con
morpeh [17]
I think the answer is WAN (wide area network)
6 0
2 years ago
Nina is trying to learn more about how computers work. She has repeatedly read that the motherboard is the "brain” of the comput
Lady bird [3.3K]

Its

Processes the data on the computer .

5 0
2 years ago
Read 2 more answers
In networking, bandwidth is the volume of computer data carried via a conductor in a period of time. Which one of these could be
masya89 [10]

Answer:

The answer is "Fiber Optic Cable".

Explanation:

In the given question options are defined, but in these options, there is some error.

The optical fiber cable is also known as internet wiring, which includes fiber strands inside an isolated housing. It is used to transferring data at a very high speed. This cable is developed for long-range data networking, high-performance connectivity, and multimedia, and other choices are wrong that can be described as follows:

  • A modem is used to transmits data over a network, that's why it is wrong.
  • Router is used to transport traffic between your computer and the internet, that's why it is wrong.
7 0
3 years ago
Caracteristicas de los valores numericos en excel
Vilka [71]
Todos los libros de Excel están formados por hojas, cada una de las hojas contiene más de 17 mil millones de celdas y en cada una de esas celdas podremos almacenar nuestros datos. Por esta razón es importante conocer los tipos de datos que podemos ingresar en cada una de las  celdas de Excel


hope this help
6 0
2 years ago
Computers process information consistently for all transactions. This creates a risk that:______
Anna007 [38]

Answer:

b. erroneous processing can result in the accumulation of a great number of misstatements in a short period of time.

Explanation:

Because of the consistent nature of processing in computers, this is capable of creating certain kinds of risk. From the option, one of the probable risk that can result from consistent information processing for multiple transactions at the same time is erroneous processing. This can therefore lead to a pile of misstatements in only a short period of time.

6 0
3 years ago
Other questions:
  • Today encoding scheme has taken over ascII by what
    5·1 answer
  • after installing a second hard drive what needs to be done to the hard drive and what do these 2 tasks do?
    13·1 answer
  • 1. Some of the music in the 1960s was used to protest social and political issues. Is music still used as a form of protest? Why
    13·1 answer
  • You have four DCs in your domain. Active Directory appears to be corrupted on one of the DCs, and you suspect a failing hard dri
    5·1 answer
  • True or False: When you share something on a friend’s Timeline, only that friend can see it.
    5·2 answers
  • Check ALL of the correct answers.
    13·1 answer
  • Will mark Brainliest!! What is the best hard disk compacity? Why?
    7·1 answer
  • Can someone help me with this lab assignment? I really do not know what should I do?
    5·1 answer
  • Catherine, a web designer, has created new content for a client's website. In order to update the company website, she needs to
    15·1 answer
  • What is the name of the method generated when you double-click a button named btnprocess in the form designer?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!