Problem Set 1
Up Problem Set 0 Problem Set 1 Problem Set 2 Problem Set 3 Problem Set 4 Problem Set 5 Problem Set 6 Problem Set 7 Problem Set 8 Problem Set 9 Problem Set 10

 

Your First C# Program(s)

Due 11:59pm Monday Sept 18

Note: you should use Visual Studio .NET for this assignment and all others in this course.

  1. Do program design exercise 18 in Chapter 2 of the text.
     
    Solution.
     
  2. Do program design exercise 19 in Chapter 2 of the text.  You should print your result nicely, for example something like:

    "52,400 seconds is the same as 14 hours, 33 minutes, and 20 seconds."
     
    Solution.
     
  3. A "mad-lib" is a sentence with certain words left out.  You ask people who don't know what the sentence is to give you words of particular parts of speech; these words are then inserted into the sentence to provide weird results.  For example:
    "The ______ professor ______ my ______, and I've never recovered."  

    This mad-lib needs an adjective, a verb (past tense), and a noun, in that order, in the three blanks.  When the blanks are filled in, it might produce the following sentence:

    "The wise professor graded my paper, and I've never recovered." 

    or

    "The purple professor ate my computer, and I've never recovered."

    Using this mad-lib idea, write a program that asks the user to input three words (an adjective, a verb, and a noun) and then prints the completed sentence.  Run your program several times (without recompiling), providing different words.  A sample output of the program might look like this:

    Welcome to the Game of Mad-lib!
    Please input an adjective: wise
    Now input a verb (past tense): graded
    Finally, input a noun: paper
    
    *** The wise professor graded my paper, and I've never recovered. ***  

    Note that, for clarity, the user input is underlined.
     
    Solution.
     

  4. Rewrite your solution to (3) in the following way:  Define a method "Query" that takes a string parameter, and returns a string result.  The string parameter is a query such as "Please input an adjective:" or "Finally, input a noun:", and the string result is the string that the user types in.
     

    Solution.