In python please!!! Write the definition of a function named countPos that reads integer values from standard input until there are none left and returns the number that are positive. The function must not use a loop of any kind.

Answers

Answer 1

Answer:Here is the method countPos    

 static int countPos(Scanner input){ //method that takes a reference to a Scanner object

  int counter=0;  // to count the positive integers  

  int number; //to store each integer value

  if(input.hasNextInt()){ //checks if next token in this scanner input is an integer value

      number=input.nextInt(); //nextInt() method of a Scanner object reads in a string of digits and converts them into an int type and stores it into number variable

      counter=countPos(input); //calls method by passing the Scanner object and stores it in counter variable

      if(number>0) //if the value is a positive number

          counter++;    } //adds 1 to the counter variable each time a positive input value is enountered

  else    { //if value is not a positive integer

      return counter;    } //returns the value of counter

  return counter; } //returns the total count of the positive numbers

Explanation:

Here is the complete program:

import java.util.Scanner; //to take input from user

public class Main { //class name

//comments with each line of method below are given in Answer section

static int countPos(Scanner input){

  int counter=0;

  int number;

  if(input.hasNextInt()){

      number=input.nextInt();

      counter=countPos(input);

      if(number>0)

          counter++;    }

  else    {

      return counter;    }

  return counter; }

public static void main(String[] args) { //start of main function

      System.out.println("Number of positive integers: " + countPos(new Scanner(System.in)));  } } //prints the number of positive integers by calling countPos method and passing Scanner object to it

The program uses hasNextInt method that returns the next token (next input value) and if condition checks using this method if the input value is an integer. nextInt() keeps scanning the next token of the input as an integer. If the input number is a positive number then the counter variable is incremented to 1 otherwise not. If the use enters anything other than an integer value then the program stops and returns the total number of positive integers input by the user. This technique is used in order to avoid using any loop. The program and its output is attached

Explanation:


Related Questions

PLZZ HELP!!!
Select the correct answer.
Brian’s team has built a new application based on the client’s requirements. They will deploy this application in multiple locations on the client side. Brian is unsure about the hardware and software specifications at the client side. Which option will help him best solve this issue?
A.
creating multiple test scripts
B.
automating test scripts
C.
creating multiple test plans
D.
creating multiple test environments
E.
communicating with the development team

Answers

Answer: Option D creating muiltiple test enviroments

Explanation: I had the same question and I hope this helps ( :

The option that will help Brain best solve this issue is by creating multiple test environments.

What is the specification of software?

A software requirements specification (SRS) is known to be a type of requirement that are often written in a document that tells more about what the software can do.

Hence in the above scenario, what will help help Brain best solve this issue is by creating multiple test environments where the client can see a demonstration and be convince in getting the product.

Learn more about application from

https://brainly.com/question/24847617

What keys on the keyboard have the ability to move the cursor around on a window?

No links and files or I report!
Will give Brainliest!​

Answers

Answer:

Press the Windows key on your keyboard. In the box that appears, type Ease of Access mouse settings and press Enter . In the Mouse Keys section, toggle the switch under Use numeric pad to move mouse around the screen to On. Press Alt + F4 to exit this menu.

HELP PLZZZZZZZZ!!!!!!!!!!!

Type the correct answer in the box. Spell all words correctly.
Before a new email application could be released to the public, it was released for a few days to some account holders of a website. The project team then collected feedback from this limited number of users and later made the email application available for public use. What type of testing did the project team use?
The project team used_____________testing for the email application.

Answers

Answer:

Its either business format franchise or business brokers

what is information richness

Answers

Information Richness is the ability of information to change understanding within a time interval.

Hope it helps. Have a great day.

Brainliest would be greatly appreciated.

___________________________________________________________

#SaveTheEarth

#SpreadTheLove

- Mitsu JK

PLZZZ HELP!!!!!!!
Select the correct answer.
Which of these examples best describes unit testing?
A.
The tester finds incorrect functionality on the home page.
B.
The login page does not accept existing user credentials.
C.
There is no database connectivity.
D.
The developer checks the loops in the procedure.
E.
Multiple users slow down the speed of the system.

Answers

Answer: A is the correct choice.

The option that is an example that describes unit testing is the developer checks the loops in the procedure.

What is unit testing?

This type of test is known to be called unit component. It is regarded as a form of a single function or code of any kind of application.

Conclusively, A good example that tells more about unit testing is the when a developer monitors the loops in the procedure so as to see if there is any error or omissions.

Learn more about unit testing  from

https://brainly.com/question/24964187


3. Java is Platform Independent. This means;
A. Java can run on any OS
need an OS to run
C. Java requires more than one OS to run
portable
D. Java is not
B. Java does

Answers

A . I hope this is right

Answer:

Java can run on any OS

need an OS to run

Across:
1. Pressing this key will cancel the data
you are typing
4. It stores the data into all of the selected
cell
Down:
2 It stores the data and moves to the next
cell to the rig
3. It stores the data and moves you to the
next cell below
5. It activates the cell for data editing
6. Clear only the formatting that is applied
to the selecte
8. It stores the data and moves you to the
next cell in the
7. The key that deletes only the content of
the selected cl​

Answers

26891jfootbggagusppdmvtgya rkofoocihhf.

PLZZZ HELP
Select the correct answer.
Ed is the manager of a software design team. He needs to call a design review meeting. Who should he call for this meeting?
A.
only the stakeholders and external reviewer
B.
stakeholders and technical team
C.
the technical team and external reviewer
D.
only the technical team
E.
only the external reviewer and stakeholders

Answers

I think the answer is C

Answer:

C: the technical team and external reviewer

Explanation:

Plato/Edmentum

Create a program that: Provides access to a rolodex (list of names and contact information). Have the program accept a name to lookup and that prints the contact information of the matching name. Use an array for names and an array for email address and another array for phone numbers. Make sure that all three arrays contain corresponding information.

Answers

Answer:

Explanation:

The following code is written in Java, it asks the user for a name and looks that name up in the names array. If it finds it prints out all the values in that same index within every array to get the name, email, and phone number. If the name is not found it prints out that the client is not found.

//The code is attached in the text file below and picture shows the output of the working code.

Characteristics of RAM​

Answers

Answer:

Short Data lifetime, Less Expensive, Needs to be refreshed often, Smaller in size, etc. tell me if you need more.

Does anyone have the answers to edhesive 4.2 lesson practice I’ve been stuck on it for like 3 months

Answers

Answer:

1. 5, 10

2. 5, 7, 9, 11

3. 21

4. 10

Explanation:

⚠️⚠️⚠️⚠️⚠️⚠️Help! What is not an advantage of using virtual machines?
You can run multiple operating systems on one physical machine.

It doesn’t take up any storage space on the physical machine.

You can save the entire state of a VM to your files.

Provides fault and security isolation for the computer’s hardware

Answers

Answer:

It doesn’t take up any storage space on the physical machine.

Explanation:

The virtual machine does take up some storage space on the physical machine.

Why data mining is crucial for the success of a business, explain with examples

Answers

Answer:

For businesses, data mining is used to discover patterns and relationships in the data in order to help make better business decisions. Data mining can help spot sales trends, develop smarter marketing campaigns, and accurately predict customer loyalty.

Write a program that prompts the user to enter their name store this value in a variable called name Prompt the user for their current age store this value in a variable called Create a variable dogAge which takes the age entered and multiplies by 7 Print to the screen “Your name is" name "and in dog years you are" dogAge "years old" To join multiple parts together in a print statement use commas: print (“Your name is", name, "and in dog years you are", dogAge)​

Answers

Answer:

Explanation:

The following code is written in Python. It prompts the user for the name and age, saves them to their own variables. Then it creates and calculates the dogAge variable. Finally, it combines all of this information and prints out the statement.

name = input("Enter your name: ")

age = input("Enter your age: ")

dogAge = int(age) * 7

print("Your name is", name, "and in dog years you are", dogAge, "years old.")

The link between violence in the media and school shootings has been proven to be direct. True/false?​

Answers

Answer:

most of the time a school shooting will be done by a kis that has been bullied and picked on a lot (aka the quiet kid ) if we could stop bullying we could decreese the number of school shootins by a lot

Explanation:

Answer:

False

Explanation:

At least in my assignment the correct answer was false.

Why is it important to think about the programming language to use?

Answers

Answer:

"The choice of programming language determines the type of game you can make."

Explanation:

Programming language enables us to write efficient programs and develop online things based on the certain type of code.

Select the correct answer.
Who takes care of the final layout of the product that meets the standards set by UX designers?
O A web developer
ОВ.
design director
OC. UX designer
OD. UI designer
Reset
Next
Hi

Answers

Answer:

UI designer

Explanation:

When using for loops and two-dimensional arrays, the outside loop moves across the ___________ and the inside loop moves across the ___________.

indexes, elements

columns, rows

elements, indexes

rows, columns

Answers

Answer: rows, columns

Explanation: :)

Which option is the default configuration of the Junk Email Options in Outlook 2016?

No Automatic Filtering
Low
High
Safe Lists Only

Answers

Answer:

No Automatic Filtering

Answer:

NO automatic filtering

Explanation:

i took the quiz

All changes
1.(01.01 LC)
To make sure you do not get too tired when using the computer for long periods of time, how often should you get up to stretch and move? (5 points)
O Every hour
O Every 10 minutes
O Every 30 minutes
O Every two hours

Answers

You should get up and move every 30 minutes

Hope  this helps

-scav

Answer:

C

Explanation:

PLS HELP WILL MARK BRAINLINESS AND 30 POINTS
In your own words in at least two paragraphs, explain why it is important, when developing a website, to create a sitemap and wireframe. Explain which process seems most important to you and why you feel most drawn to that process.

(i.e. paragraph one is why is it important and paragraph two is which process felt most important to you and why)

Answers

When creating a website, it is important to create a sitemap so that a search engine can find, crawl and index all of your website's content. a sitemap makes site creation much more efficient and simple. A sitemap also helps site developers (assuming you have any) understand the layout of your website, so that they can design according to your needs.

A wireframe is another important step in the web design process. Creating a website is like building a house. To build the house, you first need a foundation on which to build it upon. Without that foundation, the house will collapse. The same goes for a website. If you create a wireframe as a rough draft of your website before going through and adding final touches, the entire design process will become much easier. If you do not first create a wireframe, the design process will be considerably more difficult, and you are more likely to encounter problems later on.

To me, the wireframe is the most important due to the fact that is necessary in order to create a good website. In order to create a sitemap, you first need a rough outline of your website. Without that outline, creating a sitemap is impossible.

write a program that will create an array of 100 random integers in the range from [0,99] pass the array to a function, printarray(), that will print the values of the array on the monitor. pass the array to a function, sortarray(), that will sort the array. Pass the array to printarray() again and print it in increasing order

Answers

Answer:

In C++:

#include <cstdlib>  

#include <ctime>  

#include <iostream>

#include <bits/stdc++.h>

using namespace std;

void printarray(int array []){

for(int i=0; i<100; i++){         cout << array[i] << " ";    }

}

void sortarray(int array []){

sort(array, array + 100);

   printarray(array);

}

int main() {  

   int array[100];

   srand((unsigned)time(0));  

   for(int i=0; i<100; i++){  array[i] = (rand()%99);     }

   printarray(array);

   cout<<endl;

   sortarray(array);

   return 0;

}

Explanation:

See attachment for program source file where comments are used for explanation purpose


Write
algorithm to read 100 numbers
then display the largest.

Answers

Answer:

see picture

Explanation:

There is no need to store all the values, you can just keep track of the highest. Up to you to create a numbers file with 100 values.

NO LINKS
Do you need to pay monthly to stream on Twitch?

Answers

I think so yeah $$$$

Evaluate the following information that shows the projected change in employment from 2014-2024: How can job seekers use the chart? Add data to a résumé and cover letter Gain awareness of how growth trends can impact career plans Research which careers match current skills Talk to community members in a knowledgeable manner You must check the box below prior to submitting your exam! Check this box to indicate you are ready to submit your exam Submit Exam FDK191.10

Answers

Answer:

Answer is B.

Gain awareness of how growth trends can impact career plans

Explanation:

Which of the following is NOT a common type of mic:
A. Lavalier
B. Shotgun
C. Stick
D. Parabolic
E. Handheld

Answers

Answer:

Uhh all of them are mics

Explanation:

I think it’s c I hope it’s right!

3. Comparing the Utopian and dystopian views of Technology according to Street (1992) which one in your view is more applicable to your society?

Answers

Answer:

The answer is below

Explanation:

The Utopian views of technology, according to Street 1992, describe society to be in good condition in terms of politics, laws, customs, ways of life. Hence, the system is designed to improve the community for the better.

In contrast, Dystopian is described as a society that is heavily controlled by some greedy, larger than life, apocalypse group of people or government, where the rights and freedoms of people are trampled upon, thereby leading to all sorts of negativity such as suffering, poverty, intimidation, violence, disease, and break down.

The view that is more applicable to my society is the Utopia due to the following reason:

1. The people in my society accept the laid down rules and ideals. We also favor individuality and innovation.

2. My society is quite dynamic and improves over time to establish an ideal utopian world.

3. My society ensures some leaders carry the other individuals in the society along in whatever they do.

A financially stable person is able to:
A. spend money without having to save.
B. use loans to cover his or her living costs.
C. default on loan payments.
D. save money.

Answers

I think D. To save money cuz thats how financially stable people stay financially stable

Answer:

Save Money

Explanation:

D

Which one of the following is NOT a use of a database? sales statement patient list customer list inventory list

Answers

Answer:

a sales statement

Explanation:

From the different options provided, the only one that is not a use of a database would be a sales statement. These statements usually made at the end of the month or year which detail the companies' entire sales amount for that given time period. These hold alot of information but are mainly created once every cycle so there is never a need to use a database for such files. Also, these statements are rarely modified or requested so database usage would be wasted.

what are the advantage of smaw welding process​

Answers

Answer:

Explanation:

The most portable of all welding processes. No need for separate gas shielding. Can be used in a wide range of environments including outdoors, in fabrication shops, on pipelines and refineries, on ships and bridges, and more. Is not sensitive to wind and draft

Other Questions
Which function represents a quantity growing exponentially?A y = 2(0.5)^xB y = 0.5(2)^xC y = 2(0.5)^2XD y = (1/5)^x 2) Shannon and Lisa start running at the same timein the same direction3Shannon can run 1 - miles in 1/2 of an hour.42Lisa can run 2 1/2 miles in of an hour.3They both continue running at a constant rate.WINHow far apart will they be after 3/4 of an hour? 3/4y+6=0 steps in order Plz solve it And show ur work plzzz giving brainliest PLZZZ HELPSelect the correct answer.Ed is the manager of a software design team. He needs to call a design review meeting. Who should he call for this meeting?A. only the stakeholders and external reviewerB. stakeholders and technical teamC. the technical team and external reviewerD. only the technical teamE. only the external reviewer and stakeholders I'm so glad the air conditioner broke on a day where the temperature only hit 100 degrees. What is the verbal irony in this statement? (5 points) Who wouldn't be glad to have the air conditioning break on such a hot day? No one would be glad to have no air conditioning on such a hot day. The air conditioning breaking was an unexpected outcome. Air conditioning on such a hot day won't have an impact. PLEASE HELP ASAP I'M BEING TIMED!!!!!!!!!!!!!!! Some events that led to revolution in Latin America in the 1800s were:Group of answer choicesA. Napoleons invasion of Spain and Portugal led to colonial officials losing legitimacy and their authority subsequently undermined.B. A new political body named the Junta Central claimed authority in all Spanish colonies and most residents favored obedience to the Junta rather than the Spanish colonial officials.C. Both A and BD. None of the Above need helpppppp so can some of ya help me pls Why would flatboats not work on all means of river transportation?They had no mechanization to maneuver.They were able to handle currents in all directions.They could go on most trips up and down river.They did not have any overhead cover. What does Malala think her role in life is?Question 9 options:to recover fully from her injuriesto serve humanityto become a scientistto start her own school--------------------------------------------------------------------------------------------------------------------------------Why did President Obama congratulate Malala Yousafzai and Kailash Satyarthi?Question 10 options:for recovering from their injuriesfor overthrowing the Talibanfor becoming American citizensfor winning the Nobel Peace Prize 4. Completa los huecos del texto conjugando los verbos PRETRITO IMPERFECTO.En aquellos das si _____ (querer, t) ver a un amigo simplemente ______ (quedar, t) con l en un restaurante y le _______ (hablar, t) por el mvil. ________ (ser) prticamente sagrado hacer fotos a la comida ?sabes? A la gente le ________ (importar) eso, saber que _______ (comer, t) bien. Taking a break is a good thing. Adults take breaks in their jobs, and kids take breaks in school. Recess helps kids focus and stay on-task better when they are in the classroom. Going outside for recess is good for your health. The light helps us feel better, stay healthy, and keep our body in a routine. Kids get to run around at recess, which is good for physical health. Recess is a great time for kids to play together and build relationships. PLS I NEED HELP1- Authors Perspective2- Text Evidence (Quote)3- What is YOUR Perspective how does altitude and temperature influencewhere people live?help please!!! Which is one use of lasersA. reproducing images to make them clearerB. Producing a magnified image of the moonC. Cutting an iron bar into two pieces D. Making a leaf appear larger so its veins are visible Clare buys an item that normally costs $36. After using a coupon, the price came down to $27 before taxes. What percent off was this coupon? The given line passes through the points and (4, 1).On a coordinate plane, a line goes through (negative 4, negative 3) and (4, 1).What is the equation, in point-slope form, of the line that is perpendicular to the given line and passes through the point (, 3)? Question 3 Show the work please Which of these statements does NOT support the claim that Dogs are the best pets for active people?Dogs love to walk and run with their owners.Dogs love to play ball and Frisbee outdoors.Dogs are happy to sit and watch TV with their owners.Dogs need walks and exercise. Battle in your own words sentences factor: 18x+39y-15=0