CIS 3331 Midterm Exam
Question #1
The Megawatt solar panel company installs solar panels on home rooftops. The base installation
charge of $2,000 includes two panels. The charge for each additional panel is $300. The normal
waiting time for installation is two weeks, but customers can pay an express charge of 5% of the
total cost to reduce this time.
Create an application that collects the required information from the user and calculates the
charges for the installation. The user should input the following information: first name, last
name, phone, number of panels, deposit amount, and a check box for the express installation
option. When the user clicks a button to view the charges, display a group box containing the
following information: base installation charge, cost of installing additional panels, total
installation cost, deposit amount, and balance due.
E
or checking should include the following criteria:
• The name and phone fields cannot be blank
• The number of panels must be an integer between 1 and 1,000
• The deposit amount must be a numeric value greater than 0.
Use separate procedures and functions for validation and calculations whenever possible. For
example, validation of user inputs should be performed in a separate Boolean function, called
from the Click handler of the Calculate Charges button. Display e
or messages whenever
appropriate.
When the application starts, as in Figure 1, the Charges group box should be invisible. After the
user clicks the Calculate Charges button and all inputs are validated, the Charges group box
should appear, as shown in Figure 2. If the deposit amount was greater than the total charges,
change the caption of the final field from “Balance due” to “Refund”. When the user clicks the
Clear button, clear all inputs
and hide the Charges group box.
Figure 1
Figure 2
Question #2
Adding Students to a Club
Create an application that displays a list of student names in a ListBox. Use a second empty ListBox to
epresent the members of a student club. Use a button labeled Add to copy member names from the
general list to the club list. Use a button labeled Remove to remove a student from the club list. Keep a
unning count of the number of names in the club list.
The application should perform the following e
or-checking:
• Do not permit the same person’s name to be added twice.
• Avoid throwing an exception if the user clicks the Add button before having selected a student name.
• Avoid a runtime e
or if the user clicks the Remove selected member button, without having selected a
member name.
A sample of the program’s interface is shown in Figure 3.
Figure 3