Problems

  1. Simple Calculator (15 points)

    Write a program that asks the user for two non-zero numbers. The program then calculates and displays for the user: (i) the sum of the numbers, (ii) the first number minus the second number, (iii) the product of the two numbers, and (iv) the first number divided by the second number. You may use either a GUI or the keyboard scanner and output (in Chapter 2) to ask the user for the numbers and to display the answers (though the same method should be used for both).

  2. Mad Libs (10 points)

    A madlib is a word game played by one person asking the others for specific types of words (i.e. noun, verb, exclamation), and using them to fill in the blanks in a sentence. This results is a bizarre, but hopefully funny, sentence. (Wikipedia page on Mad Libs)

    Write a program that asks the user for the required type of word to fill in four blanks in a sentence or two. The program should then display the filled in sentence(s) to the user. You may use the example sentence below, or make up your own. As in problem 1.1, you may use either a GUI or the keyboard scanner and output console.

    An example sentence might be:
    It was a _____ (adjective) and ______(adjective) night, but I still managed to make it to the house of my _______ (person) to watch the ______(event).

    The user is asked to enter an adjective, an adjective, a person, and an event (but not shown the sentence).

    They enter 'white', 'silly', 'aunt', and 'Santa Claus parade'.

    The blanks are filled in, and the following sentence is shown to the user:
    It was a white and silly night, but I still managed to make it to the house of my aunt to watch the Santa Claus parade.

Submitting Your Problem Set

You should submit all problems for grading by the deadline (see class schedule for date). To submit a program, you need to demonstrate (during office hours or lab) your program and explain how it works.