Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates, it prints out, on a line by itself, the sum of all the even integers read. Declare any variables that are needed. ASSUME the availability of a variable, stdin, that references a Scanner object associated with standard input

Answers

Answer 1

Answer:

Written in Java Programming Language

import java.util.Scanner;

public class Assign{

   public static void main(String [] args)    {

   Scanner stdin = new Scanner(System.in);

   int num,sum=0;

   System.out.println("Start Inputs: ");

   num = stdin.nextInt();

   while (num>=0) {

       if(num%2== 0)

       {

       sum+=num;    

       }      

       num = stdin.nextInt();

   }

   System.out.print("Sum of even numbers: "+sum);

   

   }

}

Explanation:

I'll start my explanation from line 4

This line initializes Scanner object stdin

Scanner stdin = new Scanner(System.in);

This line declares necessary variables and initializes sum to 0

   int num,sum=0;

This line prompts user for inputs

   System.out.println("Start Inputs: ");

This line reads user inputs

   num = stdin.nextInt();

This line checks is user input is not negative (It's a loop that will be repeated continually until a negative number is inputted)

   while (num>=0) {

This line checks if user input is an even number

       if(num%2== 0)

       {

If the above condition is true, this line calculates the sum of even numbers

       sum+=num;    

       }      

This line prepares the user for next input

       num = stdin.nextInt();

   }

This line prints the calculated sum of even number; If no even number is inputted, the sum will be 0

   System.out.print("Sum of even numbers: "+sum);


Related Questions

Which of the following answers refers to a system containing mappings of domain names to various types of data, such as numerical IP addresses?

Answers

Answer:

DNS or Domain Name System

Explanation:

You can query a DNS server with a domain name to get an IP address.

You work for a public relations (PR) firm and communicate regularly with the internal team and the clients on a PR campaign. You need to quickly send and receive professional messages that may contain text files and short media. These messages need to be accessible at any time of the day and in different time zones, and they should be able to reach all members (internal and external) relatively inexpensively. Which communication channel would best suit this purpose?

Answers

Answer:

You Need To Quickly Send And Receive Professional Messages That May Contain Text Files And Short Media. These Messages Need To Be Accessible At Any Time Of The Day And In Different ... You work for a public relations (PR) firm and communicate regularly with the internal team and the clients on a PR campaign.

Explanation:

Email would likely be the best communication channel to meet these requirements. Once an email is sent, it broadcasts across servers and arrives at the recipient’s/recipients’ mailbox(es) for access at the receiving party’s/(ies’) convenience. Email is also able to have attachments, and as such, will allow for text files and smaller media files (audio, video, or otherwise) to be attached and accessed easily.

Roger is getting a $5,000 loan. Which option will allow Roger to pay off the loan and keep his payments under $100?

Answers

No roger will not be able to do that

To build a user interface that contains graphical components, the components ____. must each be added to a separate panel. must be added directly to a frame component. must be added to a panel that is contained within a frame. must be added to a frame that is contained within a panel.

Answers

Answer:

To build a user interface that contains graphical components, the components must be added to a panel that is contained within a frame.

Explanation:

Which is the right way to give comment if you are using Internet explorer as the browser? a) <!-- My First Webpage --> b) <comment> My First Webpage </comment>

Answers

Answer:

(a) <!-- My First Webpage -->

Explanation:

Comments in programming languages are chunks of texts, written as part of program code, that are not executed as actual code but rather used for making the program code easily readable and understandable. They allow programmers to explain certain lines of a program code.

Every programming language has its own way of representing comments. In HTML - HyperText Markup Language - comments are written between the following tags :

<!--

and

-->

For example, to put the text "My comment goes here" in a comment, we write:

<!-- My comment goes here -->

From the question, the text to be put is:  "My First Webpage". Therefore, we write;

<!-- My First Webpage -->

Which statement is the best description of what a macro can do in Excel 2016? It is a type of formatting users can apply to enlarge the worksheet area. It is a file type that a user can save a workbook as. It is a series of instructions contained in one command that users can apply to automate complex and/or repetitive tasks. It is a recording function that allows you to save worksheets, audio recordings, and videos that are displayed on the screen.

Answers

Answer: It is a series of instructions contained in one command that users can apply to automate complex and/or repetitive tasks

One example would be a macro that goes through a list of numbers and highlights which are duplicates. Say you had the list {1,2,3,3,4,4,4,5}. You could use one color to highlight both 3 and 4 as they repeat themselves. Or you could use different colors to show the different values. With a small list, you could highlight by hand. However, macros are more efficient with larger lists.

Answer:

It is a series of instructions contained in one command that users can execute to automate complex and/or repetitive tasks.

Explanation:

edge 2022

convert the following decimal number to its equivalent binary ,octal,hexadecimal 1920​
pls in step by step
pls help me bro

Answers

Answer:

0b11110000000 is binary

0o3600 is in octal

0x780 in hexa dec.

Explanation:its a bit complitcated to explain sorry bro!

A data set includes data from 500 random tornadoes. The display from technology available below results from using the tornado lengths​ (miles) to test the claim that the mean tornado length is greater than 2.2 miles. Use a 0.05 significance level. Identify the null and alternative​ hypothesis, test​ statistic, P-value, and state the final conclusion that addresses the original claim. LOADING... Click the icon to view the display from technology. What are the null and alternative​ hypotheses

Answers

Answer:

The answer is:

[tex]H_0:\mu=2.2\\H_1:\mu> 2.2[/tex]

Explanation:

[tex]H_0:\mu=2.2\\H_1:\mu> 2.2[/tex]

The test value of statistic t= [tex]\frac{\bar x-\mu}{\frac{s}{\sqrt{n}}}[/tex]

                                               [tex]=\frac{2.31688-2.2}{0.206915}\\\\=0.56[/tex]

The value of P = P(T>0.56)

                          =1-P(T<0.56)

                          =1-0.712

                          =0.288

Since the P value exceeds its mean value (0.288>0.05), the null assumption must not be rejected.  Don't ignore H0. This assertion, it mean length of the tornado is greater than 2.2 miles also isn't backed by enough evidence.
Other Questions
What was the population density of the original sample? What would have happened if you had inoculated an agar plate with 1 mL of the original sample? help me answer this question please with full working Where were scientific advancements being made during the dark ages Find the circumference of a circle with a radius of 15 centimeters. Round your answer to the nearest centimeter 5. Points A, B and C are allthe circle.O represents the centre.Angle AOB = 2x+28 Angle ADB = 3x-70Calculate the value for x Based on the list of word parts, what is the best definition of the word autobiographical? "related to writing about one's own life" "writing about one's relatives" "related to writing about another person's life" Which expression represents six more than x is 0.14 rational and irrational what's love like? what feels are involved? how many are 5 x 5 ? Can someone help me out with this please Write code to create a list of numbers from 0 to 67 and assign that list to the variable nums. Do not hard code the list. Save & RunLoad HistoryShow CodeLens Which of these best describes one of the themes in the play?A. Money creates happiness.B. Humanity cannot win against nature.O C. Hatred destroys the person who feels it.O D. Home is where the family is Choose the correct definition of conflict.A:Conflict is the obstacle that the character has to overcome toreach his goal.B:The nonverbal language of the script is often referred to asconflict. PLLLLLLLLLLZZZZZZZZZ can someone write an explanation of how to perform the following skills in basketball:-passing-dribbling-shooting -layups (1) 10xy' + 15xy? : Whirlpool Corporation has an agreement with IBM for the HR outsourcer to handle Whirlpool's workforce administration, compensation, recruitment, training, and performance reporting. This type of outsourcing is known as ________. A friend comes to you extremely agitated and says her husband beat her last night.She says she doesn't know what to do.You Can See She's Very panicky.Everything you suggest just seems to provoke more anxiety and fears.When you try to respond to one aspect of the problem.Your friend interrupt's frantically and jumps to another.Explain what can you do to help. [tex](2 + 6)(2 + 3)[/tex]