SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Dec 2017 My Price 8.00

For this one your are going to write code

For this one your are going to write code for the following ONE
class called:

Print_n_numbers

Here are the specifications for the class:

Make sure the class Print_n_numbers has a default constructor, i.e. it
is possible to create an object of the class by executing:

new Print_n_numbers()

The class has only one method: print.

Specs for the method: 

name: print
arguments: one int, called n.
returns: nothing
what it does: 
	it prints the numbers 1, 2, 3 ... n

if the number is 0 or negative the method print prints:

bad number

You can use the following OPTIONAL (i.e. whether you write it or not
it will not affect the tests) main method:

    public static void main(String[] aa){
	Print_n_numbers ss = new Print_n_numbers();
        Scanner scan = new Scanner(System.in);
        
        int ii = 0;
        while (ii != -1){
            System.out.print("please enter a non-zero number (-1 to end): ");
            ii = scan.nextInt();
	    System.out.println("the following is the output of ss.print(" +  ii + "):n");
            ss.print(ii);
	}
    }

If you have this main method, then you can type: Note: in the
following example what the user would enter is shown in bold face.
Otherwise it is the output of the program.

java Print_n_numbers
please enter a non-zero number: 0
the following is the output of ss.print(0):

bad number
please enter a non-zero number: -2
the following is the output of ss.print(-2):

bad number
please enter a non-zero number: 1
the following is the output of ss.print(1):

1
please enter a non-zero number: 2
the following is the output of ss.print(2):

1, 2
please enter a non-zero number: 5
the following is the output of ss.print(5):

1, 2, 3, 4, 5
please enter a non-zero number: 10
the following is the output of ss.print(10):

1, 2, 3, 4, 5, 6, 7, 8, 9, 10
please enter a non-zero number: 30
the following is the output of ss.print(30):

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
please enter a non-zero number: -1
the following is the output of ss.print(-1):

bad number

Answers

(5)
Status NEW Posted 12 Dec 2017 10:12 AM My Price 8.00

-----------  ----------- 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

Not Rated(0)