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
"In about 100 words, describe the idea behind software as a service (SaaS). In your answer, include at least three examples of e
Mama L [17]

Answer:

Explanation:

Saas refers to software as a service and can also be called software on demand .

It Isa software that is deployed over the internet rather than requiring to install an application .It offers different devices such as pay as you go , subscription model and service on demand model .

Only a compatible browser is needed to access the software .

Electronic packages or components that aree offered as an Saas

1)Shopify

2)Big commerce

3)Slack

3 0
3 years ago
Name the two types of control systems.<br> PLEASE HELP THIS WAS DUE HOURS AGOOOO
vodomira [7]

Answer:

Open loop control systems.

Closed loop control systems.

Explanation:

5 0
3 years ago
Read 2 more answers
Font size, font style, and _______ are all aspects of character formatting.
mel-nik [20]
The answer, im prettysure, is d. typeface.
hope this helps (:

6 0
3 years ago
Read 2 more answers
Tamika has received an average of 97% on all of her math tests, has done well on her homework assignments, and participates in c
sashaice [31]

Answer:

B is the correct answer.

6 0
3 years ago
Read 2 more answers
Which of the following statements is true of a cookie? a. A cookie can create copies of itself and spread to other networks to e
Ilya [14]

Answer: D.

Data about user preferences and activity is captured and stored under a cookie on a company’s Web server.

Explanation: The most common and best-known technology for user tracking is the use of cookies. Other known online website tracking tools are tracking pixels (or pixel tags), web beacons (or ultrasound beacons), and browser fingerprinting (or digital fingerprinting), amongst others.

a cookie will contain a string of text that contains information about the browser. To work, a cookie does not need to know where you are from, it only needs to remember your browser. Some Web sites do use cookies to store more personal information about you.

8 0
3 years ago
Other questions:
  • Business ethics are?
    9·1 answer
  • Given the function definition
    12·1 answer
  • Complete each sentence to describe different elements of an Excel worksheet.
    11·2 answers
  • A technician configures a switch with these commands:SwitchA(config)# interface vlan 1 SwitchA(config-if)# ip address 192.168.1.
    8·1 answer
  • What is the name of the option in most presentation applications with which you can modify slide elements? The ( answer here )op
    9·1 answer
  • John travels a lot and he needs to access his documents and services on the go. Which of these technologies allows his to access
    5·1 answer
  • These icons cannot be removed from the Dock. Finder e-mail music player Trash
    14·1 answer
  • Lab 6B: printing a binary number
    13·1 answer
  • What is the difference between a LAN and WAN? how do these two networks interact?​
    14·1 answer
  • Mechanisms that can be used to rescue accident victims
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!