The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
For this assignment you are going to write code for the following ONE
class called:
DetectPositiveNumbers
The class has only one method:
name: run
accessibility: public
returns: nothing
arguments: none
what it does:
-- method run reads an unspecified number of integers. It counts how
many positive and negative values have been read, and computes the
total and average of the input values (not counting zeros).
-- the method run ends when it detects the input 0.
-- it displays the average as a floating-point number. If only 0 is
entered, the program should print:
no numbers are entered except 0
If you add the following main method (as a method of
DetectPositiveNumbers) you will be able to run the test runs shown
here:
public static void main(String[] args){
DetectPositiveNumbers det = new DetectPositiveNumbers();
det.run();
}
Here are some sample runs:
% java DetectPositiveNumbers
Enter integers below, program ends when 0 is entered:
1
2
3
-5
3
-6
0
The number of positives is 4
The number of negatives is 2
The total is -2
The average is -0.3333333333333333
% java DetectPositiveNumbers
Enter integers below, program ends when 0 is entered:
0
no numbers are entered except 0
% java DetectPositiveNumbers
Enter integers below, program ends when 0 is entered:
2
3
0
The number of positives is 2
The number of negatives is 0
The total is 5
The average is 2.5
Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly