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
FinnZ [79.3K]
3 years ago
5

Program to calculate series 10+9+8+...+n" in java with output

Computers and Technology
1 answer:
avanturin [10]3 years ago
5 0

Answer:

import java.util.Scanner;

class Main {

 public static int calcSeries(int n) {

   int sum = 0;

   for(int i=10; i>=n; i--) {

     sum += i;

   }

   return sum;

 }

 public static void main(String[] args) {

   Scanner reader = new Scanner(System.in);

   int n = 0;

   do {

     System.out.print("Enter n: ");

     n = reader.nextInt();

     if (n >= 10) {

       System.out.println("Please enter a value lower than 10.");

     }

   } while (n >= 10);

   reader.close();

   System.out.printf("sum: %d\n", calcSeries(n));

 }

}

You might be interested in
Which of the following can you not code in a subclass? Select one: a. a method with the same signature as a method in the superc
Ray Of Light [21]
<h2>Option D: a call to a private method of the superclass</h2>

Explanation:

Option a: a method with the "same signature" is allowed in the subclass. There will not be any confusion because the object which is trying to call the method will decide whether to call the sub class or super class.

Option b: a call to a super class constructor is possible because, when you create an object of sub class automatically the super class constructor will be called. Even the sub class constructor can call the super class constructor explicitly.

Option c: A subclass can create method that's not defined by the super class

Option D: a private method is private inside the class and hence even the object of that class cannot access.

8 0
3 years ago
Why PS5 10.2 teraflops is better than 12 teraflops on the Xbox series x?
lara [203]

I really don't know why, but this is a website for homework related problems, not comparing the two new consoles.

<em>PS: I really don't know why.</em>

7 0
3 years ago
Which of the following common software packages would help a business
Jobisdone [24]

Answer:

D. Spreadsheets

Explanation:

While A also seems correct, a spreadsheet is best at collecting and organizing data. Databases would only store data while a spreadsheet would keep those records, as well as help calculate a budget or payroll.

3 0
3 years ago
Please select the word from the list that best fits the definition
GalinKa [24]

Answer:

B. Unsafe Sites

Explanation:

Unsafe Sites are not safe and contain content which may be offensive and which could also be harmful for younger children.

6 0
3 years ago
Read 2 more answers
Given a set S = {a1, a2, ..., an} of positive integers (denoting asset values), Set partitioning requires to partition S into tw
mel-nik [20]

Answer:

See the pictures attached

Explanation:

3 0
4 years ago
Other questions:
  • We may think of relationships in the E/R model as having keys, just as entity sets do. Let R be a relationship among the entity
    14·1 answer
  • Excel 2016 is primarily what type of program?
    15·1 answer
  • The key requirement in selection of the facilitator is one who is the end-user.
    8·1 answer
  • LDAP is an industry standard employed by Microsoft, which enables IT departments to use a(n) __________ structure when creating
    7·1 answer
  • You are starting a spreadsheet, and you would like 500 to appear in cell C3. You should _____.
    11·2 answers
  • 2 inventions revolutionized photography, what are they?
    10·1 answer
  • How to share pictures on brainy ​
    8·1 answer
  • To calculate perimeter of a rectangle​
    9·2 answers
  • Importance of using information and communication technology in personal life
    15·1 answer
  • Accenture has put together a coalition of several ecosystem partners to implement the principles of blockchain and Multi-party S
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!