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
Ksenya-84 [330]
3 years ago
12

Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are

read, and also compute the sum of only positive numbers, and display the count and the sum of positive numbers in different lines. Note that 0 is not included in the computations.
Computers and Technology
1 answer:
Artyom0805 [142]3 years ago
8 0

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

       compute_pos();

     }

     

     public static void compute_pos(){

     Scanner scan = new Scanner(System.in);

     int sum = 0;

     int counter = 0;

     // Prompt the user to enter an input

     System.out.println("Enter your value");

     // user input is assign to the variable value

     int value = scan.nextInt();

     

     while(value != 0){

         if (value > 0){

             sum += value;

             counter++;

         }

         System.out.println("Enter your value");

         value = scan.nextInt();

     }

     // Display the value of sum to the user

     System.out.println("The sum of the positive number is: " + sum);

     // Display the value of counter to the user

     System.out.println("The number of positive number is: " + counter);

   }

}

Explanation:

The first line import the Scanner class which allow the program to read input from the user. The class Solution is then defined. Then the main method which signify the beginning of execution in the program is defined. A method is called inside the main method.

The method compute_pos is defined. Inside the compute_pos method, a scanner object scan is declared to accept input from the user via the keyboard.

The variable sum and counter is declared and assigned to 0.

A prompt is displayed to the user to input a value. The user input is accepted and stored in the variable value.

Then a while loop is use to check the user input if it is not equal to zero. If it is equal to zero, the loop will end. Inside the loop, we first check to see if the user input is greater than 0, if it is, we add it to the variable sum and increase our counter by 1. At the end of the loop, a prompt is again display to accept input from the user.

Outside the loop, we display the sum and counter to the user.

You might be interested in
Instructions:Select the correct answer.
Gnesinka [82]
C) team leader is the answer
4 0
3 years ago
Which of the following operations would best allow you to place 3D building models at their proper height on the terrain (e.g.,
arsen [322]

Answer:

The answer is "Option C"

Explanation:

Base heights are related to it as measurements of height or z-values as they are extracted by mathematics which serves to define the ground of that same world. Once applying a datatype, it can be any entire amount, that will become the level of the function in meters beyond the ground, and wrong choices can be described as follows:

  • In option A, It is a part of extra dimensions object, that's why it is wrong.
  • In option B, It wrong because the offset tool allows the quick and easy offsetting of the lines.
  • In option D, It emphasizes the recovery charts, that's why it is incorrect.
5 0
3 years ago
Which of the following is NOT a best practice to protect data on your mobile computing device?
OleMash [197]

<u>Lock your device screen when not in use and require a password to reactivate</u> is not a best practice to protect data on your mobile computing device.

<h3>What is a mobile computing device?</h3>

Any device that was built using mobile parts, such as mobile hardware and software, is referred to as a mobile computing device. Portable devices that can function like a typical computing device in terms of operation, execution, and provision of services and applications are known as mobile computing devices.

Portable and handheld computing devices are other names for mobile computing devices.

Modern handheld devices that have the hardware and software needed to run common desktop and Web applications are generally referred to as mobile computing devices. Similar hardware and software elements found in personal computers, such as processors, random memory and storage, Wi-Fi, and an operating system, are also found in mobile computing devices. They are made specifically for mobile architecture and portability, which sets them apart from PCS.

Learn more about mobile computing devices

brainly.com/question/8189998


#SPJ1

4 0
1 year ago
A driver that approaches a controlled intersection with a signal that is not working must:
nalin [4]
You must stop at the intersection and proceed when you are aware that other turning or approaching vehicles,bicycles or pedestrians have stopped.
5 0
3 years ago
How do you think advances in processors affect corporations that discover the computers they purchased just a couple of years ag
lozanna [386]

Answer:

Increased processor speed and multi core technologies.

Explanation:

The development of processors over the years is overwhelmingly fast. The CPU use to be cumbersome, expensive and computational speed was moderate.

As it evolves, the CPU was minimized to give rise to microprocessors.

Microprocessors are very fast, running millions of processes on its core. The multiple core processors helped to increase the speed of these processors.

When there are more than one core in a processor (dual, quad or octal core), it processes data in parallel reducing the time of execution compared to a one core processor.

A company having computers with single core would need to upgrade to a new computer with multi core processor to promote speed in data processing.

3 0
2 years ago
Other questions:
  • Describe two ways in which an organizer can assist in taking notes
    8·2 answers
  • HURRY!! Ill give brainily and 25 points. Describe how Scent is related to the culture and historical period when it was created.
    15·1 answer
  • Defeating authentication follows the method–opportunity–motive paradigm.
    5·1 answer
  • The process known as "bitmapping" is defined as information in _____. PLEASE HELP FAST
    11·1 answer
  • You have heard that it is possible to improve your computer's performance by storing all related files for a particular program
    9·1 answer
  • I have a question about a hotel tv: So I’ve brought my Nintendo Switch and my dock and plugged it in to the tv. Everything seems
    13·1 answer
  • Write a java program to print the following series: <br>1 5 9 13 17...n terms​
    13·2 answers
  • Which is an advantage of using a flat file instead of a relational database?
    9·1 answer
  • E commerce is the demand of modern society both for time and money
    14·2 answers
  • What is white light?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!