Assignment
Assignment
Assignment
Course : ICT 1103 ( Structure Programming Language)
1. Write a switch statement that assigns to the variable lumens the expected brightness of a
standard light bulb whose wattage has been stored in watts . Use this table:
3. Write a program to process weekly employee time cards for all employees of an
organization. Each employee will have three data items: an identification number, the
hourly wage rate, and the number of hours worked during a given week. Each employee is
to be paid time and a half for all hours worked over 40. A tax amount of 3.625% of gross
salary will be deducted. The program output should show the employee’s number and net
pay. Display the total payroll and the average amount paid at the end of the run.
4. Determine the following information about each value in a list of positive integers.
a. Is the value a multiple of 7, 11, or 13?
b. Is the sum of the digits odd or even?
c. Is the value a prime number?
You should write a function with three type int output parameters that send back the
answers to these three questions.
Some sample input data might be: 104 3773 13 121 77 30751.
5. A barcode scanner for Universal Product Codes (UPCs) verifies the 12-digit code scanned
by comparing the code’s last digit (called a check digit ) to its own computation of the
check digit from the first 11 digits as follows:
a) Calculate the sum of the digits in the odd-numbered positions (the first, third, …,
eleventh digits) and multiply this sum by 3.
b) Calculate the sum of the digits in the even-numbered positions (the second, fourth,
…, tenth digits) and add this to the previous result.
c) If the last digit of the result from step 2 is 0, then 0 is the check digit. Otherwise,
subtract the last digit from 10 to calculate the check digit.
d) If the check digit matches the final digit of the 12-digit UPC, the UPC is assumed
correct.
Write a program that prompts the user to enter the 12 digits of a barcode separated by
spaces. The program should store the digits in an integer array, calculate the check digit,
and compare it to the final barcode digit. If the digits match, output the barcode with the
message “validated.” If not, output the barcode with the message “error in barcode.” Also,
output with labels the results from steps 1 and 2 of the check-digit calculations. Note that
the “first” digit of the barcode will be stored in element 0 of the array. Try your program
on the following barcodes, three of which are valid. For the first barcode, the result from
step 2 is 79 (0 + 9 + 0 + 8 + 4 + 0) * 3 + (7 + 4 + 0 + 0 + 5).
079400804501
024000162860
011110856807
051000138101
6. The results from the mayor’s race have been reported by each precinct as follows:
a) Write a program to do the following: a. Display the table with appropriate labels for the
rows and columns.
b) Compute and display the total number of votes received by each candidate and the
percentage of the total votes cast.
c) If any one candidate received over 50 percent of the votes, the program should display
a message declaring that candidate the winner.
d) If no candidate received 50 percent of the votes, the program should display a message
declaring a runoff between the two candidates receiving the highest number of votes;
the two candidates should be identified by their letter names.
e) Run the program once with the data shown and once with candidate C receiving only
108 votes in Precinct 4.