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
If I was to sort the months of the year in ASCENDING order alphabetically, which
bogdanovich [222]
The answer is C.) April
5 0
3 years ago
Your organization recently deployed a Windows domain controller with Active Directory. All the domain OU users need to run the s
liberstina [14]

<u>Normally windows end user can login 3 ways as follow:</u>

1. End user can Login as local account where user has not connected or even connected to local Area network LAN.

2. Next user can login into cloud accounts nothing but hot mail  accounts

3. Login to windows domain controller where end user should connect to LAN.

Purpose of installation of Windows domain controller with Active Directory is to keep trace and keep log history activities.

Due to windows domain controller with Active Directory end user desktop or laptop has control on software access also.

Every time when end user login on windows domain controller a small modified is executed whenever is required. It is not going effort the workstation performances.

Note: - Domain severs should be POWER on first.

5 0
3 years ago
3. Coaxial/telephone cable sends<br> during the data transmission<br> signal
Vlad1618 [11]

Answer:

high frequency signal.

3 0
2 years ago
OSHA requires training for employees on the hazards to which they will be exposed.
Sedaia [141]

A, OSHA does require training for employees on the hazards to which they will be exposed.


3 0
3 years ago
Read 2 more answers
Which website domains are most credible?
Leokris [45]

Credible websites usually end in the domain name .org or .edu

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following best reflects why lighting systems are used when filming on location outdoors? (Select all that apply.)
    10·1 answer
  • Explain how Deep Packet Inspection works (DPI). How is this technology beneficial to Perimeter Security? Lastly, describe a scen
    6·1 answer
  • Which is an advantage of programming with a procedural language?
    12·2 answers
  • When working with arrays, most programming languages perform ________, which means they do not allow programs to use invalid sub
    5·1 answer
  • Write a program which populates an array with integer values read from a file. We do not know how many integers are in the file,
    8·1 answer
  • . ------------ means that the two merging companiesbecame history and a new firm
    10·1 answer
  • Analyze the following output public class Test{ public static void main(String args[]){ int[] x={1,2,3,4}; //here declare array
    9·1 answer
  • What does business informWhat does business information management do?
    12·1 answer
  • Part of an algorithm which is repeated for fixed number of times is classified as.
    13·1 answer
  • unlike the barcode-based tracking system, a radio frequency identification system offers a .
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!