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
Dr. Thomas likes to follow up with her patients to make sure they were happy with their care. She sends all patients an email en
timofeeve [1]

Answer:

lean media

Explanation:

Dr. Thomas uses email as a medium of lean media to convey messages.

Lean media may be defined as the source of conveying messages that are short or of lean capacity. It is meant for instant messages and message and information that is not considered to be of out most importance. Whereas a rich media is a video chat or face to face communication.

Dr. Thomas send emails to her patients to follow up with them and also encourages her patients to call her for appointments or any questions. She uses email as a source of lean media for this communication.

8 0
2 years ago
Read 2 more answers
What are the two categories of problems that we can simply convert<br> to parallel code?
anastassius [24]
Percentage and decimals
7 0
2 years ago
Aubrey is on a Windows machine. She wants to back up her Halloween pictures on an external hard drive. Which of the following ta
Leya [2.2K]

Answer:

no clu3 lol

Explanation:

I'm stupid hahaha

8 0
3 years ago
What is one difference between a web page and a web application? Web pages provide information, while web applications allow the
Assoli18 [71]

Webpage is a page of a site, such as https://example.com/test, where the bolded text is the page.

On the other hand, web applications, or simply web apps, are found in many websites, such as here and also in Connexus. They end in either aspx or jsp, which stand for asp.net appx and javascript page, respectively.


So, your answer would be A: Web pages provide information, while web applications allow the user to do something.

Hope this was answer you were looking for. Have a nice day!

7 0
3 years ago
Write a program that reads three numbers and prints "increasing" if they are in increasing order, "decreasing" if they are in de
Lemur [1.5K]
You could assign values to variables and break it up into if else-if else statements.

<span>Pseudocode:</span>

if a < b and b < c:
    print("increasing")

else if a > b and b > c:
    print("decreasing")

else:
    print("neither")

Hope this helps.
7 0
3 years ago
Other questions:
  • Which of the following is an example of a good listening skill? A. Replying to the caller as "you" rather than using his or her
    9·2 answers
  • Computing devices translate digital to analog information in order to process the information
    8·1 answer
  • What is the name of the option in most presentation applications with which you can modify slide elements? The ( answer here )op
    9·1 answer
  • _________function tells the cin object to skip one or more characters in the keyboard buffer.
    11·1 answer
  • . When a function template has two parameterized types, one as the return value, and one as an argument, then _____.
    11·1 answer
  • ........ is a formal description of message formats and the rules for exchanging those messages
    12·1 answer
  • URGENT!!! Steve wants to change shooting and exposure settings while on his photo shoot. Which camera part will allow him to do
    12·2 answers
  • The 10 and 2 o'clock hand position on the steering wheel is no longer recommended because _____.
    13·1 answer
  • Find the basic period and basic frequency of the function g(t)=8cos(10πt)+sin(15πt)
    9·1 answer
  • How can we search person in brainly for sending request of friend
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!