This Problem Set Is Due By 11:59 PM on September 22, 2013

  1. Split 4 Digit Number (5 points)

    Write a program that reads a four-digit integer, such as 1998, and then displays it, one digit per line, like so:

    	1
    	9
    	9
    	8
          

    Your prompt should tell the user to enter a four-digit integer. You can then assume that the user follows directions. (Hint: Use the division and remainders operators.)

    Name this program Split4DigitNumber

  2. Vending Machine Makes Change (5 points)

    Write a program that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in 5-cent increments (25, 30, 35, ... , 90, 95, and 100), and the machine accepts only a single dollar bill to pay for the item. For example, a possible dialogue with the user might be:

    	Enter the price of item
    	(From 25 cents to a dollar, in 5-cent increments): 45
    	You bought an item for 45 cents and gave me a dollar,
    	so your change is:
    	2 quarters,
    	0 dimes
    	1 nickel
          

    Name this program VendingMachineMakesChange

  3. Sentence Response (5 points)

    Write a program that reads a one-line sentence as input and then displays one of the following responses:

    • If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes.
    • If the sentence ends with a question mark (?) and the input contains an odd number of characters, display the word No.
    • If the sentence ends with an exclamation point, display the word Wow.
    • In all other cases, display the words You always say followed by the input string enclosed in quotes.

    Your program does not have to check the input to see that the user has entered a legitimate sentence.

    Name this program SentenceResponse

  4. Temperature Converter (5 points)

    Write a program that allows the user to convert a temperature given in degrees from either Celcius to Farenheight or Farenheight to Celcius. Use the following formulas:

    Degrees_C = 5 (Degrees_F - 32)/9
    Degrees_F = (9/5)Degrees_C + 32

    Prompt the user to enter a temperature followed by either 'C' or 'c' for Celcius or a temperature followed by 'F' or 'f' for Farenheight. Convert the temperature to Farenheight if Celcius is entered, or to Celcius if Farenheight is entered. Display the result in a readable format. If anything other than 'C', 'c', 'F', or 'f' is entered, print an error message and stop.

    Name this program TemperatureConverter

  5. Remove Profanity (5 points)

    Suppose we are working for an online service that provides a bulletin board for its users. We would like to give our users the option of filtering out profanity. Suppose we consider the words cat, dog and llama to be profane. Write a program that reads a string from the keyboard and tests whether the string contains one or more of our profane words. Your program should find words like cAt that differ only in case. Your program should display the read string with the profanities replaced with the character '*'.

    Your program should modify lines that contain profanities only, not lines that contain words like, dogmatic or concatenate or category.

    Name this program RemoveProfanity

Please submit the completed assignment on Blackboard by attaching all your .java files. Make sure to attach all your programs to each submission.