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
Work with a partner to answer the following question: How might learning the language
AysviL [449]

Answer:

easy to learn is one similarity

longer experience needed is on difference

HOPE THIS HELPS .......

4 0
3 years ago
write a while loop that reads integers from input and calculates integer finalnum as follows: if the input is divisible by 5, ad
ira [324]

The while loop for the program that reads integers from input and calculates integer is illustrated thus:

#include <iostream>

using namespace std;

int main()

{

//declaring the variables

int userInput;

int outputVal;

outputVal = -19;

//take user input

cin >> userInput;

//take user input until negative input is given

while(userInput > 0)

{

 //if the input is divisible by 5, subtract the

 //input divided by 5 from outputVal

 if(userInput%5==0)

     outputVal -= userInput/5;  

 //if the input is not divisible by 5, add the

 //input multiplied by 5 from outputVal

  else

     outputVal += userInput*5;

   cin >> userInput; // take input

}

//print the output value

  cout << "Output value is " << outputVal << endl;

return 0;

<h3>What is a while loop?</h3>

A while loop is a control flow statement in most computer programming languages that allows code to be performed repeatedly based on a supplied Boolean condition. The while loop is similar to a looping if statement.

A "While" Loop is used to iterate over a certain block of code until a condition is met. If we wish to ask a user for a number between 1 and 10, we don't know how many times the user may enter a larger number, so we keep asking "while the number is not between 1 and 10."

Learn more about program on:

brainly.com/question/22654163

#SPJ1

7 0
1 year ago
In which view are fields set up in MS Access?
Phantasy [73]

Answer:On the Home tab, in the Views group, click View, and then click Design View. In the table design grid, select the field or fields that you want to use as the primary key. To select one field, click the row selector for the field that you want.

Explanation:

7 0
3 years ago
Read 2 more answers
How do u type faster
eduard

Answer:

by learning the right home keys and how to place the fingers

Explanation:

the left hand side : A,S,D,F

the right hand side: :, L, K, J

the two little fingers are guide keys

guide keys: letter A and column

5 0
3 years ago
Supose that there are exactly 733 monks in the world.
kramer

A statement which is true about the monks is that: There is a day of the year that is the birthday of at least 3 monks.

<h3>What is a conditional statement?</h3>

A conditional statement can be defined as a statement that can be written to contain both a hypothesis and conclusion. Thus, it typically has the form "if P then Q."

Where:

P and Q represent sentences.

<h3>What is a converse statement?</h3>

A converse statement can be defined as a type of statement that is obtained by switching (reversing) the hypothesis and conclusion of a conditional statement. This ultimately implies that, the converse of a statement is obtained by switching (reversing) the hypothesis and  conclusion of a conditional statement.

In this context, we can reasonably infer and logically deduce that a statement which is true about the monks is that there is a day of the year that is the birthday of at least 3 monks because a year only has 365 days.

Read more on conditional statement here: brainly.com/question/16951916

#SPJ1

Complete Question:

Suppose that there are exactly 733 monks in the world.

Which one of the following statements is true about the monks?

Every day of the year, it's a monk's birthday.

There is a day of the year that is the birthday of exactly 3 monks

There is a monk who celebrates his birthday on a Tuesday

There is a day of the year that is the birthday of at least 3 monks

Some monk turns years at the weekend

None of the above.​

5 0
2 years ago
Other questions:
  • Question 8 OT TU
    11·1 answer
  • If you need to use a custom theme frequently, you can save a presentation file as a(n) ____ theme file.
    12·2 answers
  • What output is produced by the following program segment? Why? (Recall that name.charAt(i) is the i-th character in the string,
    11·1 answer
  • A ______ allows a hacker to gain access to your computer and take almost complete control of it without your knowledge.
    12·2 answers
  • 1. Bones do not change position when the muscles contract and release.
    7·1 answer
  • Solid state storage stores data in erasable, rewritable circuitry, rather than on spinning disks, tape, or optical media.
    9·1 answer
  • Jacob is a website designer. Whenever his company takes on a new project, Jacob takes the initiative and comes up with ideas and
    14·1 answer
  • Consider an array of integers consisting of the numbers: 8 12 19 32 45 55 67 72 89 90 92. Suppose the binary search algorithm is
    11·1 answer
  • Based on what you know about the Sort and Find functions, return to the database file to determine the answers to the following
    7·2 answers
  • Enlist few database you use often.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!