7A

Write a program that reads a sequence of integer inputs using Scanner. Use only one prompt. Use this exact prompt "Enter a sequence of integers. Any non-integer to quit"

Then the program prints

  1. The smallest of the inputs.
  2. The largest of the inputs.
  3. The number of even and odd inputs.
  4. The average of the inputs

Print the output in exactly this fortmat:

smallest: xxx
largest: xxx
even: xxx
odd: xxx
average: xxx

Call the program Homework7APrinter

Be sure your program does not throw an exception if the user enters bad data.

For the draft, do part a.

7A draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011415336672514682198967370
A final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011415336672514682198967370&level=2

7B

Write a program that reads a string with Scanner and does these three things

  1. Prints each character of the word on a separate line. For example, if the user provides the input "Harry", the program prints
    H
    a
    r
    r
    y
  2. Prints the word in reverse. For example, if the user provides the input "Harry", the program prints
    yrraH
  3. Prints the number of vowels in the word. For this exercise, assume that a e i o u y are vowels. For example, if the user provides the input "Harry", the program prints 2
    vowels: 2

Use the prompt "Enter a word" Call the program WordPrinter

For the draft, do part a.

7B draft:http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011420253619248231599330213
7B final http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011420253619248231599330213&level=2

C

Do P6.3 (notice the P)

FactorGenerator only handles positve number. It takes more work to factor a negative number. If the number is 0 or negative, hasMoreFactors should return false. That will prevent infinite loops.

Print the factors in ascending order.

Notice you do not print 1 as a factor. That will make your work much simpler. But if the number is prime, return the number as the only factor. Foir example if the use enters 11, the output should be
11

For the draft, provide FactorGenerator with a constructor that initializes the instance variable. Make stubs for the two methods. hasMoreFactors should always return false and nextFactor should always return 0. For the draft, you do not need to add anything to the FactorPrinter provided for you , and you should not upload it.

For the final, you need to provide the implementation of the methods in FactorGenerator and finish FactorPrinter to print the factors it generates.

A difficulty here is what to do if a user calls nextFactor when no more factors exist. Normally you would throw an exception, but that is for next semester. For now just return 1 if there are no more factors when the nextFactor method is called

7C draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=1301142033312172701926159612
7C final http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=1301142033312172701926159612&level=2