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]
4 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]4 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
This Command to insert copied text anywhere in your document
harina [27]

Answer:

Paste

Explanation:

6 0
3 years ago
Read 2 more answers
Create a program in Matlab that prints the numbers from 1-100.
Burka [1]

Answer:

numbers = 1:1:100;

for num=numbers

remainder3 = rem(num,3);

remainder5 = rem(num,5);

 

if remainder3==0

disp("Yee")

else

if remainder3 == 0 && remainder5 == 0

disp ("Yee-Haw")

else

if remainder5==0

disp("Haw")

else

disp("Not a multiple of 5 or 4")

end

end

end  

end

Explanation:

  • Initialize the numbers variable from 1 to 100.
  • Loop through the all the numbers and find their remainders.
  • Check if a number is multiple of 5, 3 or both and display the message accordingly.
4 0
4 years ago
What’s my password for this app
FrozenT [24]

Answer:

I guess there isnt any password!

Explanation:

7 0
3 years ago
Read 2 more answers
Select the correct answer from each drop-down menu.
mylen [45]

Answer:

"In a VPN, a computer connects to a server and then changes the Internet Protocol of your computer" -urgurlmarie

Source: brainly.com/question/19665457, -urgurlmarie

Opinion: You're answer is correct, I'll take this step by step but by connecting your PC to an server like OpenVPN, or a paid VPN service such as Nord VPN. You are changing your Internet Protocol of your PC to that servers I.P. Address.

7 0
3 years ago
Suppose the sender wants to send the following bit stream by using bit stuffing. What would the sender transmit if the following
Helen [10]

The purpose of bit stuffing is used as a delimiter to mark the end of one frame and the beginning of the next frame.

<h3>What is Bit Stuffing?</h3>

This refers to the use of one or more information bits in order to break up the message for easy synchronization.

The parts of a frame are:

  1. Frame header
  2. Payload field
  3. Trailer
  4. Flags.

<h3>What is a Flag?</h3>

This is a bit pattern that is used to define the start and end bits in a given frame and the 8-bit pattern 01111110 as the flag is commonly used.

Hence, we can see that your question is incomplete so I gave you a general overview to help you have a better understanding of the concept.


Read more about bit stuffing here:

brainly.com/question/12949292
#SPJ1

7 0
2 years ago
Other questions:
  • A tornado may be approaching if you observe which of the following?
    15·1 answer
  • 1. Implement a method factorial(int n), that takes a number (int) and returns its factorial. Factorial of an integer is the prod
    13·1 answer
  • Discuss the use of distributed (federated) authentication systems in use at your institution. If no such system is in use, then
    5·1 answer
  • Use ONE SQL statement to show the total number of actual hours for each customer. In the output, show customer id and the total
    15·1 answer
  • What is the computer that is similar to a destop but smaller in size
    8·1 answer
  • A computer (mainframe, server, or workstation) that has an operating system enabling _____________ to access it at the same time
    11·1 answer
  • What is the purpose of the domain name?
    12·1 answer
  • I need help with yes lol please and thank you
    15·2 answers
  • Several disaster relief nonprofits want to create a centralized application and repository of information so that they can effic
    7·1 answer
  • How does digital and hybrid computers differ in portability​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!