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
timurjin [86]
4 years ago
8

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, separated by a space and on a single line, the sum of all the even integers read and the sum of all the odd integers read. declare any variables that are needed. assume the availability of a variable , stdin, that references a scanner object associated with standard input.
Computers and Technology
1 answer:
zysi [14]4 years ago
5 0
Procedure SumEvenOdd(stdin: array [0..100] of integer)
var
   i, sum_even, sum_odd: integer;

begin
   for i := 0 to 100 do begin
       if stdin[i] < 0 then
           break;
       if stdin[i] mod 2 = 0 then //even number
          sum_even := sum_even +  stdin[i]
       else 
          sum_odd := sum_odd +  stdin[i]; 

       ShowMessage('sum of even is ' + IntToStr(sum_even) + ' ' + 'sum of odd                                  is' + IntToStr(sum_odd) ) ;
   end; 

end
You might be interested in
Design a class named largeIntegers such that an object of this class can store an integer of any number of digits. Add operation
SpyIntel [72]

Answer:

Here the code is given as follows,

Explanation:

Code:

import java.util.Scanner;

//created class named largeintegers

class largeintegers{

   //class can hold a long number

   long number;

   //constructor to set number

  largeintegers(long number){

      this.number=number;

  }

  //getNumber method to get number

  long getNumber(){

      return number;

  }

  //below are some basic operations

  long addition(long num1,long num2){

       return num1+num2;

   }

   long subtract(long num1,long num2){

       return num1-num2;

   }

   long multiply(long num1,long num2){

       return num1*num2;

   }

   boolean compare(long num1,long num2)

   {

       return num1>num2;

   }

  public static void main(String[] args) {

      //declared to long numbers

      long number1,number2;

      //scanner class to take user input

      Scanner sc= new Scanner(System.in);

      //taking input numbers

      System.out.println("Enter a Number ");

      number1=sc.nextLong();

      System.out.println("Enter 2nd Number :");

      number2=sc.nextLong();

      //created two objects

      largeintegers object=new largeintegers(number1);

      largeintegers object2=new largeintegers(number2);

      //displaying two numbers

      System.out.println("Entered Numbers ");

      System.out.println(object.getNumber());

      System.out.println(object2.getNumber());

      //calling basic methods using created objects

      System.out.println("Some Operations on Given two Numbers ");

      System.out.println("Addition:"+object.addition(object.getNumber(), object2.getNumber()));

      System.out.println("Subtraction:"+object.subtract(object.getNumber(), object2.getNumber()));

      System.out.println("Multiplication:"+object.multiply(object.getNumber(), object2.getNumber()));

      System.out.println("Comparison:");

      if(object.compare(object.getNumber(), object2.getNumber())==true)

      {

          System.out.println("First Number is Greater than Second Number ");

      }

      else

      {

          System.out.println("Second Number is Greater than First Number ");

      }

      sc.close();

  }

}

Output:-

6 0
3 years ago
Write a program to print "I love to program" to the screen 2 times. Edhesive​
Anon25 [30]

Answer:

It matters what programming language you are using. It would be something like this:

print("I love to program");

print("I love to program");

(written in modified javascript)

6 0
3 years ago
The principle of time preference requries a larger payment in the future than the present. Which situation best illustrates this
gladu [14]
The answer is letter C.
3 0
3 years ago
Which of the following can you do under the fair use exceptions?
anzhelika [568]
What fair use exceptions are you talking about? There are thousands on fair use exceptions.
8 0
3 years ago
Plzz helps me with hw
IceJOKER [234]

Answer:

1. not statistical

2. statistical

3. statistical

4. not statistical

5. statistical

6. not statistical

7. statistical

Explanation:

The statistical can compare more then 1 thing to make it reasonable.

4 0
4 years ago
Other questions:
  • Using a "word" of 3 bits, list all of the possible signed binary numbers and their decimal equivalents that are representable in
    11·1 answer
  • . Reorder the following efficiencies from smallest to largest:
    9·1 answer
  • In what year was google launched on the web?
    14·1 answer
  • What is the term for a server at the highest level of the Domain Name System (DNS)?
    15·1 answer
  • The Many–Hands Problem makes it difficult to determine who should be held accountable for mistakes since:
    7·1 answer
  • 1)What is Big Data?
    14·1 answer
  • Why authentication processes and features important
    10·1 answer
  • . Is it conceivable to design a secure operating system for these computer systems? Give arguments for and against.
    6·1 answer
  • What is operating system​
    10·2 answers
  • write the few lines of code that prompts the user to enter a series of exam scores, stopping when the user has entered an exam s
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!