Exercises

  1. 14.3 Extend the program in Fig. 14.26 to include a CheckBox for every font-style option. [Hint: Use logical exclusive OR (^) rather than testing for every bit explicitly.]

  2. 14.4 Create the GUI in Fig. 14.41 (you do not have to provide functionality).

    Fig. 14.41 Calculator GUI.

  3. 14.5 Create the GUI in Fig. 14.42 (you do not have to provide functionality).

    Fig. 14.42 Printer GUI.

  4. 14.6 (Temperature Conversions) Write a temperature conversion program that converts from Fahrenheit to Celsius. The Fahrenheit temperature should be entered from the keyboard (via a TextBox). A Label should be used to display the converted temperature. Use the following formula for the conversion:

    Celsius=(5/9)×(Fahrenheit32)
  5. 14.7 (Enhanced Painter) Extend the program of Fig. 14.38 to include options for changing the size and color of the lines drawn. Create a GUI similar to Fig. 14.43. The user should be able to draw on the app’s Panel. To retrieve a Graphics object for drawing, call method panelName.CreateGraphics(), substituting in the name of your Panel.

    Fig. 14.43 Drawing Panel GUI.

  6. 14.8 (Guess the Number Game) Write a program that plays “guess the number” as follows: Your program chooses the number to be guessed by selecting an int at random in the range 1–1000. The program then displays the following text in a label:

    
    I have a number between 1 and 1000--can you guess my number?
    Please enter your first guess.
    

    A TextBox should be used to input the guess. As each guess is input, the background color should change to red or blue. Red indicates that the user is getting “warmer,” blue that the user is getting “colder.” A Label should display either “Too High” or “Too Low,” to help the user zero in on the correct answer. When the user guesses the correct answer, display “Correct!” in a message box, change the Form’s background color to green and disable the TextBox. Recall that a TextBox (like other controls) can be disabled by setting the control’s Enabled property to false. Provide a Button that allows the user to play the game again. When the Button is clicked, generate a new random number, change the background to the default color and enable the TextBox.

  7. 14.9 (Fuzzy Dice Order Form) Write an app that allows users to process orders for fuzzy dice. The app should calculate the total price of the order, including tax and shipping. TextBoxes for inputting the order number, the customer name and the shipping address are provided. Initially, these fields contain text that describes their purpose. Provide CheckBoxes for selecting the fuzzy-dice color and TextBoxes for inputting the quantities of fuzzy dice to order. The app should update the total cost, tax and shipping when the user changes any one of the quantity fields’ values. The app should also contain a Button that when clicked, returns all fields to their original values. Use 5% for the tax rate. Shipping charges are $1.50 for up to 20 pairs of dice. If more than 20 pairs of dice are ordered, shipping is free. All fields must be filled out, and an item must be checked for the user to enter a quantity for that item.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset