DEVRY CIS170B all weeks ilabs [ all 7 weeks ]

Question # 00030290 Posted By: steve_jobs Updated on: 11/02/2014 02:20 PM Due on: 12/17/2014
Subject Computer Science Topic General Computer Science Tutorials:
Question
Dot Image

Print
iLab 1 of 7: Getting Started (Your First C# Programs) - (45 points)
Note!

Submit your assignment to the Dropbox located on the silver tab at the top of this page.

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Remember This!

Connect to the iLab here.

iLAB OVERVIEW

Scenario and Summary

Welcome to Programming with C#. The purpose of this three-part lab is to walk you through the following tutorial to become familiar with the actions of compiling and executing a C# program.

Deliverables

Submit the following to this week's Dropbox:

  1. A zipped Visual Studio project folder for each programming exercise. Refer to the Deliverables section of the Week 1 iLab page for detailed instructions on how to zip a project folder.
  2. A single MS Word file named YourLastName_Lab1_ex1.docx, containing the following items:
    • The source code for each part/exercise: Your source code should use proper indentation, include meaningful comments, and be error free. Start each with a specification that includes your name, the lab and exercise number, and a description of what the program accomplishes, similar to this:
    • /* Specification:
      First Name Last Name
      Lab 1 Exercise #
      This program does X */

    • Labeled screenshot(s) demonstrating that each exercise produces correct results
  3. NOTE: A screenshot of a window can be created by first clicking on it to activate it. Next, press the key or key combination your specific computer uses to do a "print screen" (typically the Prnt Scrn or Prnt key in combination with the ctrl or FN key). Then, click the MS Word "paste" option to paste the screenshot into the MS Word file.

Objectives and Grading

Lab Objectives:

  1. How to create a project
  2. How to enter and save a program
  3. How to compile and run a program
  4. Given a simple problem using input and output, be able to code and test a program that meets the specifications.
  5. Be able to debug a simple program of any syntax and logic errors.

Your lab grade will be based upon:

  1. the formatting of your source code;
  2. the use of meaningful identifiers;
  3. the extent of internal documentation; and
  4. the degree to which an exercise's specifications are met.

Preparation: If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

iLab Steps

Part A: Getting Started

Step 1:Start the Application

Locate the Visual Studio 2010 icon and double click to open. Under Applications, click on the Microsoft Visual Studio.NET 2010 icon to open the C# software.

Step 2:Create a C# Console Project

Choose File->New Project, and click Console Application. In the project name box, enter LAB1A. Your screen should look like the screen below. If so, press the OK button.


Step 3:Delete All Code in Program.cs

Your screen should now look like what you see below. Now, highlight all of the code that you see [Ctrl + A] and press the Delete key. You will not need this code because you will now be getting experience writing every line of a new program.

Step 4:Type in Program

Now enter the following C# program exactly as you see it. Use the tab where appropriate. (Note: C# is case sensitive.) Instead of John Doe, type your name.

  • class Hello
  • {
    • static void Main()
    • {
      • // display output
      • System.Console.WriteLine("John Doe");
      • System.Console.WriteLine("CIS170B – Programming using C#");
      • System.Console.WriteLine("\n\n\nHello, world!\n\n");
      • System.Console.WriteLine("EOJ");
      • System.Console.ReadLine();
    • }
  • }

Step 5:Save Program

Save your program by clicking File on the menu bar and then clicking Save Program.cs, or by clicking the Save button on the toolbar or Ctrl + S.

Step 6:Build Solution

To compile the program, click Debug on the menu bar and then click the Build Solution or Build LabAoption. You should receive no error messages in the Error List window below the program. If you see some error messages, check the code above to make sure you didn't key in something wrong. You can double click on each error message to better navigate to the area where the problem might be. Once you make your corrections to the code, go ahead and build the solution again.

Step 7:Execute the Program

Once you have no compile errors, to execute or run your program, either:

  • click Debug on the menu bar, and then Start Debugging
  • click the right arrow icon on the menu bar; or
  • press the F5 key.

Step 8:Capture the Output

Print a picture of your screen output. (Do a print screen and paste this into your MS Word document.)

Step 9: Print the Source Code

Copy your source code and paste it into your Word document.

End of Part A

Part B: Calculate Total Tickets

Step 1:Create New Project

Make sure you close your previous program by clicking File >> Close Solution. Now, create a new project and name it LAB1B.

Step 2:Type in Program

Like before, delete the code that is automatically created and enter the following program. Type in your name for Developer and current date for Date Written.
// ---------------------------------------------------------------
// Programming Assignment:LAB1B
// Developer:________________________
// Date Written:________________________
// Purpose:Ticket Calculation Program
// ---------------------------------------------------------------
  • using System;
  • class FirstOutputWithUsing
  • {
    • static void Main()
    • {
      • // create variables and load values
      • int childTkts, adultTkts, totalTkts;
      • childTkts = 3;
      • adultTkts = 2;
      • // process (calculation)
      • totalTkts = childTkts + adultTkts;
      • // display output
      • Console.WriteLine(totalTkts);
      • // pause
        Console.Write("\nPress Enter to continue...");
        Console.ReadLine();
    • }
  • }

Step 3:Save Program

Save your program by clicking File on the menu bar and then clicking Save Program.cs, or by clicking the Save button on the toolbar or Ctrl + S.

Step 4:Build Solution

To compile the program, click Build on the menu bar and then click the Build Solution or Build LabBoption. You should receive no error messages. If you see some error messages, check the code above to make sure you didn't key in something wrong. Once you make your corrections to the code, go ahead and click Build >> Build Solution again.

Step 5:Execute the Program

Once you have no syntax errors, to execute or run your program, click Debug on the menu bar and then click Start Debugging.

Step 6:Comment the Program

Go back to the editor and insert meaningful comments that show that you understand what each line of code does.

Step 7:Capture the Output

  1. Run the program again.
  2. Capture a screen print of your output. (Do a PRINT SCREEN and paste into your MS Word document.)
  3. Copy your commented code and paste it into your document

End of Part B

Part C: Payroll Program

Step 1:Create a New Project

  1. Make sure you close your previous program by clicking File >> Close Solution.
  2. Create a new project and name it LAB1C.
  3. This time, do not delete the code that gets automatically created. Instead, insert your code right between the curly braces, as illustrated below.
  • static void Main(string [] Args)
  • {
    • // your code goes here!
  • }
Include a comment box like what you coded in Part B at the very top of your program.

Step 1a:Write Your Own Program

Write a program that calculates and displays the take-home pay for a commissioned sales employee after deductions are taken. The employee receives 7% of his or her total sales as his or her gross pay. His or her federal tax rate is 18%. He or she contributes 10% to his or her retirement program and 6% to Social Security. Use the Processing Logic provided in Step 2 below as a guide. The program's output should look something like this:

Enter weekly sales:28,000
Total sales:$28,000.00
Gross pay (7%):$1,960.00
Federal tax paid:$352.80
Social security paid:$117.60
Retirement contribution:$196.00
Total deductions:$666.40
Take home pay:$1,293.60
Press any key to continue.

Step 2:Processing Logic

Basic Logic and Flowchart

Input: Prompt the user for the weekly sales.
Process: Perform the calculations. The employee receives 7% of his or her total sales as his or her gross pay. His or her federal tax rate is 18%. He or she contributes 10% to his or her retirement program and 6% to Social Security.

Output: Display the results.

Pseudocode:

  1. Declare variables
  2. Accept Input – weeklySales
  3. Calculate Gross Pay = Weekly Sales * .07
  4. Calculate Federal Tax = Gross Pay * .18
  5. Calculate Social Security = Gross Pay * .06
  6. Calculate Retirement = Gross Pay * .10
  7. Calculate Total Deductions = Federal Tax + Social Security + Retirement
  8. Calculate Total Take Home Pay = Gross Pay – Total Deductions
  9. Display the following on separate lines and format variables with $ and decimal
    1. Total Sales Amount:value of weekly sales
    2. Gross Pay (.07):value of gross pay
    3. Federal Tax paid (.18):value of federal tax
    4. Social Security paid (.06):value of social security
    5. Retirement contribution (.10):value of retirement
    6. Total Deductions:value of total deductions
    7. Take Home Pay:value of take home pay

Step 3:Save Program

Save your program by clicking File on the menu bar and then clicking Save Program.cs, or by clicking the Save button on the toolbar or Ctrl + S.

Step 4:Build Solution

To compile the program, click Debug on the menu bar and then click the Build Solution or Build LabCoption. You should receive no error messages. If you see some error messages, check the code above to make sure you didn't key in something wrong. Double-click on an error to navigate to its location in the code. Once you make your corrections to the code, go ahead and click Debug >> Build Solution again.

Step 5:Execute the Program

Once you have no syntax errors, to execute or run your program, click Debug on the menu bar and then click Start Debugging, or press the right arrow icon or the F5key

Step 6:Capture the Output

  1. Capture a screen print of your output. (Do a PRINT SCREEN and paste into your MS Word document.)
  2. Copy your commented code and paste it into the Word document.

End of Part C

END OF LAB

After you have completed your lab, complete the following for each part of the lab (if there are multiple parts).

  1. Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.)
  2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.
  3. Save the Word document as CIS170B_Lab01_B_LastName_FirstInitial.docx.
  4. Upload all three projects folder and save the compressed file as CIS170B_Lab01_B_LastName_FirstInitial.Zip.
  5. Submit both the compressed project file and the Word document to the weekly Dropbox for this lab.

Zipping and Submitting Your Project Files

When you submit your project files, you will want to send the entire project folder that is created by MS Visual Studio when you create the project, along with your MS Word file. Use your favorite compression tool to zip the full contents of both projects, zip the single zip file, and submit the zip file to your Dropbox.

The following illustrates how to zip up a sample project folder using Winzip.If you do not have a compression tool, you can use the Windows Explorer "Send to Compressed (zipped) Folder" command by performing the following steps.

  1. Select the folder(s)
  2. Right click
  3. Select "Winzip"
  4. Expand the right arrow
  5. Select "Add to folder name.zip"
  6. Submit the resulting folder to iLab Dropbox

  1. Select the folder(s)
  2. Right click
  3. Select "Send to"
  4. Expand the right arrow
  5. Select "Compressed (zipped) Folder"
  6. Select the name and location of the resulting compressed folder
  7. Submit the resulting folder to iLab Dropbox


Print

Lab 2 of 7: Decisions - (45 points)

Note!

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, pleaseclick here.

Remember This!

Connect to the iLab here.

iLAB OVERVIEW

Scenario and Summary

You will code, build, execute, debug, and test two programs using decision structures. The first program will calculate the shipping charge based on a given purchase amount. The second program translates a given TV channel to its call sign.

Deliverables

Submit the following to this week's Dropbox:

  1. A zipped Visual Studio project folder for each programming exercise. Refer to the Deliverables section of the Week 1 iLab page for detailed instructions on how to zip a project folder.
  2. A single MS Word file named YourLastName_Lab1_ex1.docx containing the following items:
    • The source code for each program in the lab: Your source code should use proper indentation, include meaningful comments, and be error free. Start each with a specification that includes your name, the lab and exercise number, and a description of what the program accomplishes, similar to this:
    • /* Specification:
      First Name Last Name
      Lab 1 Exercise #
      This program does X */

    • Labeled screenshot(s) of the output windows for each program, showing that each program produces correct results
  3. NOTE: A screenshot of a window can be created by first clicking on it to activate it. Next, press the key or key combination your specific computer uses to do a "print screen" (typically the Prnt Scrn or Prnt key in combination with the ctrl or FN key). Then, click the MS Word "paste" option to paste the screenshot into the MS Word file.

Objectives and Grading

Lab Objectives:

  1. To be able to design program logic using either a flowchart or pseudocode
  2. To be able to define and use data types
  3. To be able to prompt the user for input
  4. To be able to use the assignment statement for calculations
  5. To be able to display output to the console in a formatted manner
  6. To be able to debug a program of syntax and logic errors
  7. To be able to make decisions

Your lab grade will be based upon:

  1. the formatting of your source code;
  2. the use of meaningful identifiers;
  3. the extent of internal documentation; and
  4. the degree to which an exercise's specifications are met.

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

iLab 2


Part A: Calculate Shipping Charge

Requirements

Your mission: Write a program that gets the amount of a purchase from the user and then calculates the shipping charge, based on the following table:

$0.00 - $250.00:$5.00
$250.01 - $500.00:$8.00
$500.01 - $1,000.00:$10.00
$1,000.01 - $5,000.00:$15.00
over $5,000.00:$20.00

Sample output from program:

Enter a purchase amount to find out your shipping charges.

Please enter the amount of your purchase: 234.65
The shipping charge on a purchase of $234.65 is $5.00.
Press any key to continue . . .

Tips

Best practice: Put yourself in the place of the program. What questions would you ask a customer in order to get the best input? How would you determine the correct shipping charges if you had to make the decisions yourself? Write out the questions you would ask yourself on paper as pseudocode and/or in Visual Studio as C# comments, and then implement them one by one, testing as you go. Remember to not write too much at one time. Always add and test functionality incrementally!

You can use the pseudocode below as a guide:

Prompt the user for the sale amount
Is sale amount greater than $5,000.00?
If so, shipping is $20.00If not, is sale amount greater than $1,000.00?
If so, shipping is $15.00If not, is sale amount greater than $500.00?
If so, shipping is $10.00If not, is sale amount greater than $250.00?
If so, shipping is $8.00If not, is sale amount greater than $0.00
shipping is $5.00If not
shipping is $0.00

If shipping is $0.00Display "Error incorrect input"If notDisplay sale amount and shipping charge





n

Part B: TV Channel to Call Sign

Requirements

Your mission: Write a program that translates a TV channel (1 through 10) in your area to its respective call sign. For example, in the New York metropolitan area, channel 2 translates to WCBS. If a channel is unused in your area, tell the user that this is the case.

Sample output from program:

Translate TV Channel Number to Call Sign

Enter channel number: 1
Channel 1 is undesignated in your area

Enter channel number: 2
Call sign for channel 2 is WCBS

Enter channel number: 6
Call sign for channel 6 is WRNNDT

Tips

Best practice: Put yourself in the place of the program. What steps would you personally need to perform in order to process a channel translation yourself? Write out those steps on paper as pseudocode and/or in Visual Studio as C# comments, and then implement them one by one, testing as you go. Remember to not write too much at one time. Always add and test functionality incrementally!

Pseudocode:Although there are several valid ways to write the program, the following is an outline of one way to design the overall logic.

  • Declare variables for channel and call sign
  • Get channel number from user
  • Use appropriate decision structure to translate number to call sign
  • If number is valid in area
    • Print out translation



Print
iLab 3 of 7: Looping - (45 points)
Note!

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, pleaseclick here.

Remember This!

Connect to the iLab here.

iLAB OVERVIEW

Scenario and Summary

You will design, code, build, execute, and debug a program that will use looping to determine the final score of dives based on individual judges' scores as well as a given dive's degree of difficulty.

Deliverables

Submit the following to this week's Dropbox:

  1. A zipped Visual Studio project folder for each programming exercise. Refer to the Deliverables section of the Week 1 iLab page for detailed instructions on how to zip a project folder.
  2. A single MS Word file named YourLastName_Lab1_ex1.docx containing the following items:
    • The source code for each part/exercise: Your source code should use proper indentation, include meaningful comments, and be error free. Start each with a specification that includes your name, the lab and exercise number, and a description of what the program accomplishes, similar to this:
    • /* Specification:
      First Name Last Name
      Lab 1 Exercise#
      This program does X */

    • Labeled screenshot(s) demonstrating that each exercise produces correct results
  3. NOTE: A screenshot of a window can be created by first clicking on it to activate it. Next, press the key or key combination your specific computer uses to do a "print screen" (typically the Prnt Scrn or Prnt key in combination with the ctrl or FN key). Then, click the MS Word "paste" option to paste the screenshot into the MS Word file.

Objectives and Grading

Lab Objectives:

  1. Become familiar with the different types of looping structures.
  2. To be able to debug a program of syntax and logic errors
  3. To be able to use the debug step-into feature to step through the logic of the program and to see how the variables change values

Your lab grade will be based upon:

  1. the formatting of your source code;
  2. the use of meaningful identifiers;
  3. the extent of internal documentation; and
  4. the degree to which an exercise's specifications are met.

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

iLab Steps


Part A:Requirements - DIVE Scoring Program

Your mission: The state diving commission wants to computerize the scoring at its diving competitions. You've been hired to write a program to automate the scoring of dives. Following are the requirements for the program.

After each dive, the user will be prompted to enter the:

  • diver's name;
  • diver's city;
  • degree of difficulty (ranges from 1.00 to 1.67); and
  • scores from five judges (scores can range from 0 to 10).

If an invalid score is entered, an error message will be displayed. The user will be prompted for the score repeatedly until a valid score is entered.

The program will then display the following information:

  • Diver's name
  • Diver's city
  • Dive final score: This is calculated by dropping the highest and lowest of the five judges' scores. The remaining three scores are added together, and the result is divided by 3 and then multiplied by the degree of difficulty.

The program will then prompt the user if she/he wants to process another dive. The user can type "Y" or "y" to continue, and "N" or "n" to quit.

Sample output:

Diver's name: Sue Jones
Diver's city: Dallas
Dive degree of difficulty: 1.9
Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)
Dive degree of difficulty: 2
Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)
Dive degree of difficulty: 1.2

Judge #1 score: 45
Invalid score - Please reenter (Valid Range: 0 - 10)
Judge #1 score: 3
Judge #2 score: 4.5
Judge #3 score 6.7
Judge #4 score 89
Invalid score - Please reenter (Valid Range: 0 - 10)
Judge #4 score 8
Judge #5 score: 9.2

Diver: Sue Jones
City: Dallas
Dive score: 7.68

Do you want to process another dive (Y/N)? y

Diver's name: Dave Smith
Diver's city: Houston
Dive degree of difficulty: 1.1
Judge #1 score: 5.7
Judge #2 score: 6.8
Judge #3 score:: 7.6
Judge #4 score: 8.7
Judge #5 score: 6.7

Diver: Dave Smith
City: Houston
Dive score: 7.74

Do you want to process another diver (Y/N)? N

Tips

Best practice: Note that a good way to implement the code is to write a first version for only a single dive without validating input. Put yourself in the place of the program. What steps would you personally need to perform in order to process a single dive yourself? Write out those steps on paper as pseudocode and/or in Visual Studio as C# comments, and then implement them one by one, testing as you go. After you have a single dive process working, implement one of the input validations, or the outer loop that repeats the whole process. Whichever you choose, remember to not write too much at one time. Always add and test functionality incrementally!

Pseudocode:Although there are several valid ways to write the program, the following is an outline of one way to design the overall logic.

Declare and initialize variables: name, city, judge score, highest score, lowest score, total score
Loop while there are dives to process

  • Get diver's name and city
  • Get degree of difficulty
    • Loop to validate input
    • End Loop

  • Loop five times to get judges' scores
    • Loop to Validate input
    • End Loop
    • Update highest and lowest scores if need be
    • Add score to total score

  • End Loop
  • Calculate the final score (subtract highest and lowest scores from total score, divide by 3, multiply by degree of difficulty)
  • Display the diver's information and final dive score
  • Prompt the user if he or she wants to process another dive
  • End-Loop





iLab 4 of 7: Methods - (45 points)

Note!

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, pleaseclick here.

Remember This!

Connect to the iLab here.

iLAB OVERVIEW

Scenario and Summary

You will code, build, and execute a program that simulates the dialing of a phone using methods.

Deliverables

Submit the following to this week's Dropbox:

  1. A zipped Visual Studio project folder for each programming exercise. Refer to the Deliverables section of the Week 1 iLab page for detailed instructions on how to zip a project folder.
  2. A single MS Word file named YourLastName_Lab1_ex1.docx containing the following items:
    • The source code for each program in the lab: Your source code should use proper indentation, include meaningful comments, and be error free. Start each with a specification that includes your name, the lab and exercise number, and a description of what the program accomplishes, similar to this:
    • /* Specification:
      First Name Last Name
      Lab 1 Exercise #
      This program does X */

    • Labeled screenshot(s) of the output windows for each program, showing that each program produces correct results
  3. NOTE: A screenshot of a window can be created by first clicking on it to activate it. Next, press the key or key combination your specific computer uses to do a "print screen" (typically the Prnt Scrn or Prnt key in combination with the ctrl or FN key). Then, click the MS Word "paste" option to paste the screenshot into the MS Word file.

Objectives and Grading

Lab Objectives:

  1. Distinguish between by value, by ref, and out parameter types.
  2. Call class methods using by value, by ref, and out parameters.
  3. Write your own class methods using by value, by ref, and out parameters.
  4. To be able to define and use global named constants
  5. To be able to debug a program of syntax and logic errors
  6. To be able to use the debug step-into feature to step through the logic of the program and to see how the variables change values

Your lab grade will be based upon:

  1. the formatting of your source code;
  2. the use of meaningful identifiers;
  3. the extent of internal documentation; and
  4. the degree to which an exercise's specifications are met.

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

iLab Steps


Step 1:Requirements - Phone Dialing Program

Your mission: A prepaid phone service needs a program that converts alphanumeric keyboard input into a phone number. The user will input eight characters and the program will output either an error message or the translated seven-digit phone number. The input may contain digits, letters, or both. Letters can be uppercase or lowercase.

The program will perform the conversion per a standard telephone keypad layout.

0

5

J K L

1

6

M N O

2

A B C

7

P Q R S

3

D E F

8

T U V

4

G H I

9

W X Y Z

The program implements the following methods.

  • Main(): Declares seven character variables and passes these to the following methods by reference:
    • ProcessInput(): gets user input and performs the conversion
    • ShowResults(): displays the results
  • GetInput(): Gets seven characters from the user and stores them into the seven variables Main() has passed by reference.
  • ProcessInput(): Calls ToDigit() for each, passing each character variable by reference, and returns one of these codes to Main() by value:
    • 0 if there were no input errors
    • -1 if there were input errors

Input errors include the following:

    • The first character is 0 (seven-digit phone numbers can't start with 0).
    • The first three characters are "555" (no phone numbers start with 555).
    • Any character is not a digit or an uppercase or lowercase letter.
  • ToDigit(): Converts a character (passed by reference) to its corresponding digit per the table above, and returns one of these codes to ProcessInput() by value:
    • 0 if the character is valid (a digit or uppercase or lowercase letter)
    • -1 if the character is not valid
  • ShowResults(): Writes converted telephone number to the screen, inserting a dash (-) between the third and fourth digits, and accepts the seven character variables from Main() by reference.

Sample Output:

Enter a 7 character phone number: 2132121
The converted phone number is: 213-2121

Enter a 7 character phone number: 2scdfER
The converted phone number is: 272-3337

Enter a 7 character phone number: 555resw
Invalid input, please try again.

Enter a 7 character phone number: 0988765
Invalid input, please try again.

Enter a 7 character phone number: 12345678
Invalid input, please try again.

Enter a 7 character phone number: @34*uy
Invalid input, please try again.

Tips

Best practice: Don't try to write too much at a time! First, write an outline in comments based on the requirements and the pseudocode. Then, implement declaring seven char variables. Make sure to fix any compiler errors before implementing more. Then, write and call an empty GetInput() method that accepts parameters, but does nothing but return a dummy value. Make sure you can pass the seven character variables by reference without compiler errors before implementing any of the GetInput() logic. Keep working incrementally like this, testing as you go. Set breakpoints and use the debugger at each phase to make sure your logic is working correctly. Then, use the same approach to implement the other methods. Test each phase with valid input before handling any invalid conditions.

Pseudocode

  • ProcessInput( ) Method
    • Get 7 characters from the user and store them in the 7 variables that Main() has passed by reference
    • Call ToDigit() for each of the 7 characters
      • If toDigit returns an error code (-1), return an error code (-1)
    • If the first character is 0, return an error code (-1) to Main()
    • If the first three characters are 555, return an error code (-1)
    • If there are no errors, return 0
  • ToDigit ( ) Method
    • Convert the characters (passed from ProcessInput() by reference) to upper case
    • Use a switch statement to translate characters into their corresponding digits.
      • Write a case statement for each digit and for each valid uppercase letter
      • Write a default case that returns an error code (-1) for invalid letters
    • If there are no invalid letters, return 0
  • ShowResults ( ) Method
    • Display the Phone Number using the character variables Main() has passed by reference
  • Main() Method
    • Declare 7 char variables
    • Get user input by calling the GetInput() method, passing it the 7 variables by reference
    • Perform the conversion by calling the ProcessInput( ) method, passing it the 7 variables by reference
    • Display an error message or call ShowResults(), depending on the code ProcessInput() returns

END OF LAB







Print
iLab 5 of 7: Arrays and Strings - (45 points)
Note!

Submit your assignment to the Dropbox located on the silver tab at the top of this page.

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Remember This!

Connect to the iLab here.

iLAB OVERVIEW

Scenario and Summary

You will code, build, and execute two programs requiring arrays and ArrayLists. The first program will determine statistics for a video game tournament. The second program will alphabetize a list of last names.

Deliverables

Submit the following to this week's Dropbox:

  1. A zipped Visual Studio project folder for each programming exercise. Refer to the Deliverables section of the Week 1 iLab page for detailed instructions on how to zip a project folder.
  2. A single MS Word file named YourLastName_Lab1_ex1.docx containing the following items:
    • The source code for each program in the lab: Your source code should use proper indentation, include meaningful comments, and be error free. Start each with a specification that includes your name, the lab and exercise number, and a description of what the program accomplishes, similar to this: /* Specification: First Name Last Name Lab 1 Exercise # This program does X */
    • Labeled screenshot(s) of the output windows for each program, showing that each program produces correct results

NOTE: A screenshot of a window can be created by first clicking on it to activate it. Next, press the key or key combination your specific computer uses to do a "print screen" (typically the Prnt Scrn or Prnt key in combination with the ctrl or FN key). Then, click the MS Word "paste" option to paste the screenshot into the MS Word file.

Objectives and Grading

Lab Objectives:

  1. To be able to explain the need for arrays in a program
  2. To be able to determine the appropriate array data type to use in a given program
  3. To be able to write a program that implements arrays
  4. To be able to explain the way memory is allocated for arrays in a program
  5. To be able to explain the fact that arrays are objects in C#
  6. To be able to write a program that implements an ArrayList

Your lab grade will be based upon:

  1. the formatting of your source code;
  2. the use of meaningful identifiers;
  3. the extent of internal documentationl; and
  4. the degree to which an exercise's specifications are met.

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

iLab Steps


Part A: Tournament Stats

Requirements

Your mission: Write a program to determine statistics for a video game tournament. The user will input names and scores of all tournament players. The program will calculate the average score and display the players who scored below average.

The program will implement these functions:

  • Main(): Declares variables for the number of players and average score, and two arrays of size 100: one to store player names and the other to store their respective scores. Calls the following functions in sequence, passing necessary parameters by reference:
    • InputData( ): Gets player names and scores from the user and stores them into the two arrays for an unknown number of players up to 100.
    • DisplayPlayerData(): Displays each player's name and score.
    • CalculateAverageScore( ): Calculates the average score and returns it by value.
    • DisplayBelowAverage( ): Displays the names and scores of players who scored below average.

Sample output:

Enter Player Name (Q to quit): Bob

Enter score for Bob: 3245

Enter Player Name (Q to quit): Sue

Enter score for Sue: 1098

Enter Player Name (Q to quit): Dave

Enter score for Dave: 8219

Enter Player Name (Q to quit): Pat

Enter score for Pat: 3217

Enter Player Name (Q to quit): Q

NameScore
Bob3245
Sue1098
Dave8219
Pat3217
Average Score: 3944.75
Players who scored below average

NameScore
Bob3245
Sue1098
Pat3217
Press any key to continue . . .

Tips

Best practices:Don't try to write too much at a time! First, write an outline in comments based on the requirements and the pseudocode. Then, implement each function one at a time. Start each by writing a shell that just accepts data and perhaps prints it out for testing purposes. Test by calling the function from Main(). Then, add more functionality. Keep working incrementally, compiling and testing as you go. Set breakpoints and use the debugger at each phase to make sure your logic is working correctly. Then, use the same approach to implement each of the other functions.

Pseudocode

  • Main Function
    • Declare player and score arrays, and variables for number of players and average score.
    • Call the InputData( ) function, passing arrays and number of players variable by reference
    • Call the DisplayPlayerData( ) function, passing arrays and number of players variable by reference
    • Call the CalculateAverageScore( ) function, passing arrays and number of players by reference. Store returned value in average variable.
    • Display the average score
    • Call the DisplayBelowAverage( ) function, passing arrays and number of players variable by reference, passing average variable by value

  • InputData function
    • Loop while the number of players is less than the length of the array
    • Prompt for the player's name
    • If the user entered Q, break out of the loop
    • Prompt the user for the player's score
    • Add 1 to the number of players

  • DisplayPlayerData function
    • Loop to display the name and score of each player

  • CalculateAverageScore function
    • Loop to add up the scores
    • Divide by the number of players to calculate the average score
    • Return the average score to main

  • DisplayBelowAverage function
    • Loop to display the names and scores of all players who scored below the average score

END OF PART A





Part B: Alphabetical Order

Requirements

Your mission: Write a program to alphabetize a list of last names. The user will input an undetermined number of last names. The program will display the number of names entered and alphabetized lists of the names in ascending (A-Z) and descending (Z-A) order.

Your program will store the names in an ArrayList object. It will use various ArrayList properties and methods to implement the program requirements.

Sample output:

Enter a last name: Roberts
Keep going? (Y/N): y
Enter a last name: DeLay
Keep going? (Y/N): y
Enter a last name: Foreman
Keep going? (Y/N): y
Enter a last name: Ganguly
Keep going? (Y/N): n

4 last names entered

Names in Ascending Order

DeLay
Foreman
Ganguly

Names in Descending Order

Roberts
Ganguly
Foreman
DeLay

Tips

Best practices:Don't try to write too much at a time! First, write an outline in comments based on the requirements and the pseudocode. Then, work on instantiating an ArrayList object, followed by implementing the loop that will get user input. As always, keep things simple and implement incrementally. Review the list of ArrayList methods and properties in the textbook and experiment with the ones you think you'll need.

Pseudocode

  • Main function
  • Instantiate ArrayList object
  • Loop to get last names, until user wants to quit
    • Add each last name to the ArrayList
  • Display the count of the last names
  • Sort the ArrayList
  • Loop to display the names
  • Reverse the order of the ArrayList
  • Loop to display the names

END OF LAB









Print
iLab 6 of 7: Menu-Driven Applications (GUI) - (45 points)
Note!

(See the Syllabus section "Due Dates for Assignments & Exams" for due dates.)

Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, pleaseclick here.

Remember This!

Connect to the iLab here.

iLAB OVERVIEW

Scenario and Summary

You will code, build, and execute two programs requiring GUI. The first program will ask the user to input a password and then reenter it for verification. The second program is a number guessing game that generates a random number and asks the user to input his or her guess.

Deliverables

Submit the following to this week's Dropbox:

  1. A zipped Visual Studio project folder for each programming exercise. Refer to the Deliverables section of the Week 1 iLab page for detailed instructions on how to zip a project folder.
  2. A single MS Word file named YourLastName_Lab1_ex1.docx containing the following items:
    • The source code for each program in the lab: Your source code should use proper indentation, include meaningful comments, and be error free. Start each with a specification that includes your name, the lab and exercise number, and a description of what the program accomplishes, similar to this:
    • /* Specification:
      First Name Last Name
      Lab 1 Exercise#
      This program does X */

    • Labeled screenshot(s) of the output windows for each program, showing that each program produces correct results
  3. NOTE: A screenshot of a window can be created by first clicking on it to activate it. Next, press the key or key combination your specific computer uses to do a "print screen" (typically the Prnt Scrn or Prnt key in combination with the ctrl or FN key). Then, click the MS Word "paste" option to paste the screenshot into the MS Word file.

Objectives and Grading

Lab Objectives:

  1. To be able to explain the need for menus in a program
  2. To be able to determine ways to implement menus in a Windows application
  3. To be able to understand the classes and objects used in a Windows application
  4. To be able to write a Windows application

Your lab grade will be based upon:

  1. the formatting of your source code;
  2. the use of meaningful identifiers;
  3. the extent of internal documentation; and
  4. the degree to which an exercise's specifications are met.

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

iLab Steps


Part A: Password Program

Requirements

Write a Windows application that simulates entering a password. The user enters a password and clicks Next. Then, the user types the password again and clicks Continue. The program will display a Message Box that displays either that the passwords match or that they don't match.

Sample output:

I type in Bob in the password field and click Next.

I type in Bob in the second password field and click Continue.

Login window

Message displayed if the passwords match:

Message displayed if the passwords are different:

Tips

Best practice: First make sure to read through this week's lecture and try it yourself! Then, you'll be in good shape for this exercise.

Pseudocode:

Next Button Event Handler Method

  • If the first password textbox is not blank
    • Make visible the second password textbox, the Done button, and the labels
  • Else
    • Put "You must enter a password" in the label
  • End-If

Done Button Event Handler Method

  • If the first password text box is not empty
    • If the first password text box equals the second password textbox
      • Display the message "Passwords are the same"
    • Else
      • Display the message "Passwords are different"
    • End-If
  • Else
    • Display the message "You must enter a password"
  • End-If

END OF PART A


Part B: Number Guessing Game

Requirements

Write a Windows application that randomly generates a number from 0 through 100. Prompt the user to guess the number. Let the user know if the guess is too low, too high, or is the correct number. Give the user another chance to guess the number. The user keeps guessing until he or she gets it correct.

Sample output:

I entered a number and pressed the button.

I pressed the button and the box and message are cleared.

I entered a number and pressed the button.

After entering several numbers, I got the following:

The following message is displayed when the guess is right.

Tips

Pseudocode:

Form constructor method

  • Randomly pick a target number between 0 and 100

Evaluate Button Click Event Handler Method

  • If the guess text box is not blank
    • Pull the guess from the text box
    • Add 1 to the number of guesses

    • If the guess is less than the target
      • Make the Evaluate button invisible
      • Change the label message to "Too Low!!"
      • Make the label message visible
      • Change the background color of the form to LightSeaGreen
      • Make the Try Again button visible
    • Else if the guess is greater than the target
      • Make the Evaluate button invisible
      • Change the label message to "Too High!!"
      • Make the label message visible
      • Change the background color of the form to SlateBlue
      • Make the Try Again button visible
    • Else
      • Display a message indicating the user guessed correctly and display the number of guesses it took.
    • End-If
  • End-If

Try Again Button Click Event handler

  • Clear the guess text box
  • Make the label message and Try Again buttons invisible
  • Make the Evaluate button visible

END OF PART B

END OF LAB






DEVRY CIS170B WEEK 7 ILAB
Dot Image
Tutorials for this Question
  1. Tutorial # 00029738 Posted By: steve_jobs Posted on: 11/02/2014 02:24 PM
    Puchased By: 4
    Tutorial Preview
    The solution of DEVRY CIS170B all weeks ilabs [ all 7 weeks ]...
    Attachments
    devry_cis170.zip (301.1 KB)
    Recent Feedback
    Rated By Feedback Comments Rated On
    fra...icks Rating The homework was precisely done 02/15/2016
    Te...ama Rating Appreciate the quality of work 10/13/2015

Great! We have found the solution of this question!

Whatsapp Lisa