Don't wanna be here? Send us removal request.
Link
DEVRY CIS 170 C iLab 7 of 7 Sequential Files
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-c-ilab-7-of-7-sequential-files
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 7 of 7 Sequential Files
Lab # CIS CIS170C-A7 Lab 7 of 7: Sequential Files Lab Overview - Scenario/Summary
You will code, build, and execute a program that requires sequential files to create an address database.
Learning Outcomes
Continue using a menu system with console applications Be able to write a console application Demonstrate entering, appending, storing, and retrieving records Be able to write lines of output to a text file in order to create a reportDeliverables
Section
Deliverable
Points
Step
Program Listing and Output
45
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.
Lab:
Step 1: Requirements: An Address Database
Create a C++ console application that will store and retrieve names and addresses in a text file.
The program should do the following.
It should accept a series of names and addresses from the console. The user's input should be written to a text file in the CSV format described in the lecture, but do not include the field names in the first row of the file. Read the records from the text file, and display them in a user-friendly format. Provide a menu to allow the user to append records to the file, display the records, or exit the application.
Build upon the code below to complete the assignment.
//Specification: Append and display records in a address database
#include #include #include
using namespace std;
void menu(void); void writeData(void); void readData(void); string * split(string, char); const char FileName[] = "TestAddress.txt";
int main () { menu(); return 0; } //end main
void menu(void) { //allow user to choose to append records, display records or exit the program
}//end menu
void writeData(void){ //Write the Address Info to a file
}//end write data
void readData(void){ //read data from a file //use the split function to break a //deliminated line of text into fields
}//end read data
string * split(string theLine, char theDeliminator){ //Break theline into fields and save the fields to an array. //Each field will occupy one element in a character array. //theLine is a string with fields separated with theDeliminator character. //Assumes the last field in the string is terminated with a newline. //Useage: string *(lineBuffer, ','); //determine how many splits there will be so we can size our array int ; for(int ; i <theline.size();=""> if (theLine[i] == theDeliminator) splitCount++; } splitCount++; //add one more to the count because there is not an ending comma
//create an array to hold the fields string* theFieldArray; string[splitCount];
//split the string into seperate fields string ; int ; for(int ; i <theline.size();="" i++){="" read="" each="" character="" and="" look="" for="" the=""> if (theLine[i] != theDeliminator) { theField += theLine[i]; //build the field } else { //the deliminator was hit so save to the field to the array theFieldArray[commaCount] = theField; //save the field to the array ; commaCount++; } } theFieldArray[commaCount] = theField; //the last field is not marked with a comma... return theFieldArray; } //end split
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
The pseudocode for the writeData function is shown below.
Start
open the text file to append
start do while loop
Allow user to enter name
store name (using getline method)
Allow user to enter city
store city (using getline method)
.
.
write name, city, etc. to the file
end loop
close the file
End
The program input should appear similar to this.
Append Records Name..........John Smith Street.........902 Union Ave City............Any Town State...........TX Zip Code......78552 "Enter another Record? (Y/N) "
The file structure should look like this.
John Smith, 902 Union Ave, Any Town, TX, 79552 Eric Jones, 345 State Way, Fresno, CA, 93432 ...
The file output should appear similar to the following.
Show Records __________________________________________ Record #1 Name...........John Smith Street..........902 Union Ave City.............Any Town State...........TX Zip Code......78552 __________________________________________ Record #2 Name...........Eric Jones Street..........345 State Way City.............Fresno State...........CA Zip Code.......93432 __________________________________________ (A)ppend Records, (S)how Records, (E)xit
Step 3: Create a New Project
Create a new project and name it LAB7. Write your code using the processing logic in Step 2. Make sure you save your program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all the syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic, if necessary, until the results of the program execution are what you expect.
Step 5: Print Screenshots and Program
Capture a screen print of your output. (Do a print screen and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab07_LastName_FirstInitial.
END OF LAB
0 notes
Link
DEVRY CIS 170 C iLab 6 of 7 Menu-Driven Application
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-c-lab-6-of-7-menu-driven-application
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 6 of 7 Menu-Driven Application
Lab # CIS CIS170C-A6 Lab 6 of 7: Menu-Driven Application Lab Overview - Scenario/Summary
You will utilize classes in the design of this program. You will code, build, and execute an Automated Teller Machine (ATM) Menu-Driven Console Application.
Learning outcomes:
To be able to explain the need for menus in a program To be able to determine ways to implement menus in a Windows console application To be able to understand the classes and objects used in a Windows console application To be able to write a Windows console applicationDeliverables
Section
Deliverable
Points
Lab 6
Step 5: Program Listing and Output
45
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located on the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.
Lab:
Part A: Password Program
Step 1: Requirements
Write a windows console application that simulates an Automated Teller Machine (ATM) menu similar to the following (this program assumes you are uniquely logged in).
Welcome to the DeVry Bank Automated Teller Machine
Check balance Make withdrawal Make deposit View account information View statement View bank information Exit
The result of choosing #1 will be the following: Current balance is: $2439.45 The result of choosing #2 will be the following: How much would you like to withdraw? $200.50
The result of choosing #3 will be the following: How much would you like to deposit? $177.32
The result of choosing #4 will be the following:
Name: (Student’s first and last name goes here)
Account Number: 1234554321
The result of choosing #5 will be the following: 01/01/11 - McDonald’s - $6.27
01/15/11 - Kwik Trip - $34.93
02/28/11 - Target - $124.21
The result of choosing #6 will be the following: Devry Bank, established 2011
(123) 456-7890
12345 1st St.
Someplace, NJ 12345
The result of choosing #7 will be the following: *Exit the program - terminate console application.
Step 2: Processing Logic
You will create a Menu Builder class (for menu applications), a Test Menu class (for Main), and a MenuBuilder.h for a total of three files as a demonstration of understanding, creating, and using classes.
Using the pseudocode below, write the code that will meet the requirements.
Create a Test Menu class
For main method and to call the Menu Driven class
Create a MenuBuilder Class
This will be where you create statements for the following:
1. Check balance
2. Make withdrawal
3. Make deposit
4. View account information
5. View statement
6. View bank information
7. Exit
Create a MenuBuilder.h
Include a header file in your program. 2. This will be where you utilize standardized Identifiers, preprocessor directives, classes, namespaces, and so forth.
Step 3: Create a New Project
Create a new project and name it LAB6. Write your code using the Processing Logic in Step 2. Make sure you save your program.
Step 4: Compile and Execute
a) Compile your program and eliminate all syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic if necessary until the results of the program execution are what you expect.
Step 5: Print Screenshots and Program
Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab06B_LastName_FirstInitial.
END OF ILAB
0 notes
Link
DEVRY CIS 170 C iLab 5 of 7 Arrays and Strings
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-c-ilab-5-of-7-arrays-and-strings
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 5 of 7 Arrays and Strings
Lab # CIS CIS170C-A5 Lab 5 of 7: Arrays and Strings Lab Overview - Scenario/Summary
You will code, build, and execute two programs requiring arrays and strings. First program (Video Game Player Program): Determine the average score for a group of players and then determine who scored below average.
Second program (Pig Latin): Convert words in a phrase to pig latin.
Learning outcomes:
Be able to explain the need for arrays in a program. Be able to determine the appropriate array data type to use in a given program. Be able to write a program that implements arrays. Be able to explain the way memory is allocated for arrays in a program. Be able to explain the fact that arrays are objects in C++. Be able to write a program that implements strings.Deliverables
Section
Deliverable
Points
Part A
Step 5: Program Listing and Output
20
Part B
Step 5: Program Listing and Output
25
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located on the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.
Lab:
Part A: Video Game Player Program
Step 1: Requirements
Write a program to do the following:
In main, declare a PlayerName Array and a Score Array. Declare the size of the arrays to be 100. In the InputData function, input the player name and score into the arrays for an unknown number of players up to 100.
In the DisplayPlayerData function, display the name and score of each player. Numberofplayers
In the CalculateAverageScore function, calculate the average score and return it by value. numberofplayers
In the DisplayBelowAverage function, display the name and score for any player who scored below the average. Do not use global variables.
Number of players
Output from Program:
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
Name Score
Bob 3245
Sue 1098
Dave 8219
Pat 3217
Average Score: 3944.75
Players who scored below average
Name Score
Bob 3245
Sue 1098
Pat 3217
Press any key to continue . . .
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Main Function
Declare the player name and score arrays, number of players, and average score.
Call the InputData function
Call the DisplayPlayerData function
Call the CalculateAverageScore function and assign the returned value in average score
Call the DisplayBelowAverage function
InputData function
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
End-While
DisplayPlayerData function
Display the name and score of each player
CalculateAverageScore function
Add up the scores and divide by the number of scores to calculate the average score
Display the average score
Return the average score to main
DisplayBelowAverage function
Display the names and scores of all players who scored below the average score
Step 3: Create a New Project
Create a new project and name it LAB5A. Write your code using the Processing Logic in Part A, Step 2. Make sure you save your program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic if necessary until the results of the program execution are what you expect.
Step 5: Print Screen Shots and Program
Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab05A_LastName_FirstInitial.
END OF PART A
Part B: Pig Latin
Step 1: Requirements
Write a program that will input a phrase and convert it to pig latin. Put each word in a separate element of a string array. Remove the first letter from each word and concatenate it to the end of the word followed by “ay.”
Sample Output from Program:
*****************************************************
* You will be prompted to enter a string of *
* words. The string will be converted into *
* Pig Latin and the results displayed. *
* Enter as many strings as you would like. * ******************************************************
Enter a group of words or ENTER to quit: Computer Programming is fun to learn!
Original words: Computer Programming is fun to learn!
New Words: omputercayogrammingprayiswayunfayotayearnlay!
Enter a group of words or ENTER to quit: Quit
Pig Latin Hint: If a word begins with one or more consonants, move the consonant or consonant cluster to the end of the word. Add the letters "ay" to the end of the word. So, "pig" would be "igpay," and “latin” would be “atinlay.”
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Main function
Display the heading
While the condition is true
Prompt the user for group of words or Enter to quit
Display original words
Call function pigLatinString( )
End while
pigLatinString( ) function
Declare and initialize string variables len, counter, start, begin, word and newString
While condition is true
Call find() and pass a space and start as parameters and return the returned value
to start
if start equals to string::npos
jump outside the loop permanently
call substr() function
display the word
update newString
increment start by one
assign start to begin
End While
Call substr()
Update newString
Return newString
Step 3: Create a New Project
Create a new project and name it LAB5B. Write your code using the Processing Logic in Part B, Step 2. Make sure you save your program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic if necessary until the results of the program execution are what you expect.
Step 5: Print Screen Shots and Program
Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab05B_LastName_FirstInitial.
END OF LAB
0 notes
Link
DEVRY CIS 170 C iLab 4 of 7 Functions
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-c-ilab-4-of-7-functions
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 4 of 7 Functions
Lab # CIS CIS170C-A4 Lab 4 of 7: Functions Lab Overview – Scenario/Summary
You will code, build, and execute a program that simulates the dialing of a phone using functions.
Learning outcomes:
Distinguish between pass by value and by reference. Call functions using &. Write functions using value and reference. Be able to define and use global named constants. Be able to debug a program with syntax and logic errors. 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.Deliverables
Section
Deliverable
Points
Lab 4
Step 5: Program Listing and Output
45
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.
Lab:
Step 1: Requirements: Phone-Dialing Program
Write a program that simulates the dialing of a phone number.
A user will input an 8-place number, for example: UN9-3177 (note that the hyphen is considered a digit).
The rules for entering phone numbers follow.
8 places It may have numbers, letters, or both. The phone number cannot begin with 555. The phone number cannot begin with 0. The hyphen must be in the 4th position. No other characters (@#$%^&*()_+=\|/><="" p="">
If all of the rules are met, you will output a message to the console that reads like the following. Phone Number Dialed: UN9-3177 *the number entered
If all of the rules are not met, then you output one of the following error messages to the console.
ERROR - Phone number cannot begin with 555 ERROR - Phone number cannot begin with 0 ERROR - Hyphen is not in the correct position ERROR - An invalid character was entered
It will then prompt the user to try again.
This should be a lot of fun!
Here are some great things to think about as you begin your program!
Define a function named ReadDials() that reads each digit and letter dialed into 8 separate char variables (DO NOT USE ARRAYS). All the digits are sent back through parameters by reference. Then, for each digit, the program will use a function named ToDigit(), which receives a single char argument (pass by reference) that may be a number or a letter of one of the digits dialed. If it is a number, then return 0 by value indicating that it is a valid digit. If the digit is a letter, then the number corresponding to the letter is returned by reference, and return 0 by value indicating that it is a valid digit. Here are the letters associated with each digit.
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
If the digit entered is not one of the valid digits or one of the valid letters, return –1 by value indicating that you have an invalid digit.
A phone number never begins with a 0, so the program should flag an error if such a number is entered. Make ReadDials() return –2 in this case.
A phone number never begins with 555, so the program should flag an error if such a number is entered. Make ReadDials() return –3 in this case.
A phone number always has a hyphen (-) in the 4th position. Make ReadDials() return –4 in this case (if it doesn't have a hyphen in the 4th position). If a hyphen is in any other position, it is considered an invalid digit.
If the phone number is valid, the main calls the AcknowledgeCall function to write the converted number to the output file.
All the logic of the program should be put in functions that are called from Main(): ReadDials() and AcknowledgeCall().
The ToDigits() function is called from the ReadDials() function and is used to convert each letter entered individually into a digit and to verify that the user has entered a valid phone number. Have the program work for any number of phone numbers.
In the ToDigits() function uses the toupper function to convert any letters entered to uppercase. All the error messages are to be written to the output file from main() based on the return value from the functions.
Continue processing until the user enters a Q.
You will set up the 8 char variables to hold the digits of the phone number in main() and pass the variables to the functions by reference.
Sample Output from the Program
Enter a phone number (Q to quit): 213-2121
Phone Number Dialed: 213-2121
Enter a phone number (Q to quit): asc-dfer
Phone Number Dialed: 272-3337
Enter a phone number (Q to quit): 555-resw
ERROR - Phone number cannot begin with 555
Enter a phone number (Q to quit): 098-8765
ERROR - Phone number cannot begin with 0
Enter a phone number (Q to quit): 12345678
ERROR - Hyphen is not in the correct position
Enter a phone number (Q to quit): @34-*uyt
ERROR - An invalid character was entered
Enter a phone number (Q to quit): Q
Press any key to continue . . .
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Main Function Declare the char variables for the 8 digits of the phone number
while true Call the ReadDials function passing the 8 digits by reference. ReadDials returns an error code by value.
If the return value is -5, exit the do while loop
If the error code is -1, display the error message "ERROR - An invalid character was entered". If the error code is -2, display the error message "ERROR - Phone number cannot begin with 0". If the error code is -3, display the error message "ERROR - Phone number cannot begin with 555". If the error code is -4, display the error message "ERROR - Hyphen is not in the correct position". Otherwise, call the AcknowledgeCall function End-While
ReadDials function
Input the first digit If a Q was entered, return -5. Input the rest of the phone number
Call the ToDigit function for each of the 7 digits not for digit 4 If ToDigit returns -1, return -1 If digit 4 is not a hyphen, return -4. If digit 1 is 0, return -2. If digits 1 - 3 are 5, return -3 Otherwise, return 0
ToDigit function Convert the digit to upper case Use a switch statement to determine if the digit is valid and convert the letters to digits
If the digit is invalid, return -1. If the digit is valid, return 0.
AcknowledgeCall function Display the Phone Number.
Step 3: Create a New Project
Create a new project and name it LAB4.
Write your code using the processing logic in Step 2 (above). Make sure that you save your program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all the syntax errors.
b) Build your program and verify the results of the program. Make corrections to the program logic, if necessary, until the results of the program execution are what you expect.
Step 5: Print Screen Shots and Program
Capture a screen print of your output (do a print screen and paste into an MS Word document). Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word document as Lab04_LastName_FirstInitial.
END OF LAB
0 notes
Link
DEVRY CIS 170 C iLab 3 of 7 Looping
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-c-ilab-3-of-7-looping
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 3 of 7 Looping
Lab # CIS CIS170C-A3 Lab 3 of 7: Looping Lab Overview – Scenario/Summary
You will code, build, and execute a program that will use looping to determine the score for a diver based on individual judge’s scores.
Learning outcomes:
Become familiar with the different types of looping structures. Be able to debug a program of syntax and logic errors. 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.Deliverables
Section
Deliverable
Points
Lab 3
Step 6: Program Listing and Output
45
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located on the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.
Lab:
Step 1: Requirements - DIVER Scoring Program
Your State Dive Association presently scores its diving competitions with pencil and paper. They would like for you to design and develop a Dive Program in C++.
The paper forms that they presently use have the following: Diver’s Name, City JudgeScore1 - The scores entered are from 0 to 10. JudgeScore2 JudgeScore3 JudgeScore4 JudgeScore5 DegreeOfDifficulty - This is assigned once for each diver. OverAllScore - The overall score is the individual diver’s scores totaled and then divided by the degree of difficulty. The highest and lowest scores are removed as they are often skewed entries. Total the three scores left, divide them by 3, and then multiply that by the DegreeOfDifficulty. The degree of difficulty ranges from 1.00 to 1.67. Display the diver's information and overall score.
When the competition is complete, there is a summary reportcreated that lists the total number of divers and the average of the overall scores.
Lab hints: When writing this lab, use nested loops. A nested loop is when one loop is completely contained in another loop. In an inner loop, you will read the five scores one at a time. Every time you read the score (in the loop), you will compare the score to the highest so far and also to the lowest so far so you can determine the highest and lowest scores, in addition to adding the scores up one at a time.
You also need to have your program process multiple divers. Put this in an outer loop. After you process the information for one diver, prompt the user if she/he wants to process another diver. Allow the user to type either a “Y” or “y” to enter another diver's information; otherwise, exit the loop. Write an event summary by calculating and displaying the average score for all divers and the total number of divers participating.
Garbage in Garbage Out (GIGO): The data being entered by the user needs to be validated. Scores by judges may range between 0 and 10. If the user enters an invalid score, display an error message, and prompt for the score again. Keep doing this until the user enters the score correctly. The degree of difficulty may range from 1.00 to 1.67.
Sample output from program
Report to the media
Event: Diving competition
Enter the diver's name: Sue Jones
Enter the diver's city: Dallas
Enter the score given by judge #1: 45
Invalid score - Please reenter (Valid Range: 0 - 10)
Enter the score given by judge #1: 3
Enter the score given by judge #2: 4.5
Enter the score given by judge #3: 6.7
Enter the score given by judge #4: 89
Invalid score - Please reenter (Valid Range: 0 - 10)
Enter the score given by judge #4: 8
Enter the score given by judge #5: 9.2
What was the degree of difficulty? 1.9
Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)
What was the degree of difficulty? 2
Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)
What was the degree of difficulty? 1.2
Diver: Sue Jones, City: Dallas
Overall score was 7.68
Do you want to process another diver (Y/N)? y
Enter the diver's name: Dave Smith
Enter the diver's city: Houston
Enter the score given by judge #1: 5.7
Enter the score given by judge #2: 6.8
Enter the score given by judge #3: 7.6
Enter the score given by judge #4: 8.7
Enter the score given by judge #5: 6.7
What was the degree of difficulty? 1.1
Diver: Dave Smith, City: Houston
Overall score was 7.74
Do you want to process another diver (Y/N)? n
EVENT SUMMARY
Number of divers participating: 2
Average score of all divers: 7.71
Press any key to continue . . .
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Write report heading
Loop as long as there are divers to process
Input diver's name and city
Initialize highest score, lowest score and total score
Using a do-while loop input the 5 judge's scores
Validate the score to ensure it is between 0 and 10
Add score to total
Determine highest and lowest scores
Input and validate the degree of difficulty
Calculate the overall diver's score
Display the diver's information and overall score
Add diver's overall score to the final score
Add 1 to the number of divers
Prompt the user if she wants to process another diver
End-Loop
Calculate the average score for all divers
Display the number of divers and the average score for all divers
Step 3: Create a New Project
Create a new project and name it LAB3.
Write your code using the Processing Logic in Step 2. Make sure to save your program.
Step 4: Build Solution
To compile the program, click Debug then Build solution (F7). 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.
0 notes
Link
DEVRY CIS 170 C iLab 2 of 7 Decisions
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-ilab-2-of-7-decisions
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 2 of 7 Decisions
Lab # CIS CIS170C-A2 Lab 2 of 7: Decisions Lab Overview - Scenario/Summary
You will code, build, and execute two programs requiring decisions. The first program will determine the smaller of two numbers input on the screen. The second program will calculate the shipping charge based on the purchase amount input on the screen.
Learning outcomes:
To be able to design program logic using either a flowchart or pseudocode To be able to define and use data types To be able to prompt the user for input To be able to use the assignment statement for calculations To be able to display output to the console in a formatted manner To be able to debug a program of syntax and logic errors To be able to make decisionsDeliverables
Section
Deliverable
Points
Part A
Step 7: Program Listing and Output
20
Part B
Step 7: Program Listing and Output
25
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.
Locate the Visual Studio 2010 icon and launch the application.
Lab:
Part A: Determine Smallest Number
Step 1: Requirements
Write a program that inputs two numbers and determines which of the two numbers is the smallest. If the numbers are equal, display a message that they are equal.
Sample output from program:
You will be asked to enter two numbers.
The smallest value will be displayed or a message if they are the same.
Please enter a numeric value: 4
Please enter a numeric value: 7
The smallest value is 4
Press any key to continue . . .
AND THEN:
Please enter a numeric value: 7
Please enter a numeric value: 4
The smallest value is 4
Press any key to continue . . .
Step 2: Pseudocode
Using the pseudocode below, write the code that will meet the requirements:
Display description of program
Prompt the user for the first number
Prompt the user for the second number
If first number equals second number
Display the two numbers are equal
Else
If first number is greater than second number
Assign second number to smallest
Else
Assign first number to smallest
End-If
Display smallest number
End-If
Step 3: Create a New Project
Create a new project and name it LAB2A. Write your code using the processing logic in Part A, Step 2.
Step 4: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, or by clicking the Save button on the toolbar, or Ctrl + S.
Step 5: Build Solution
To compile the program, click Debug and then Build solution (F7). 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 6: 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 7: Capture the Output
Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word Document as Lab02A_LastName_FirstInitial.
END OF PART A
Part B: Calculate Shipping Charge
Step 1: Requirements
Write a program that inputs the amount of the purchase and 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 . . .
Step 2: Pseudocode
Using the pseudocode below, write the code that will meet the requirements.
Display program information
Prompt the user for the sale amount
If sale amount > $5,000.00
shipping is $20.00
Else if sale amount > $1,000.00
shipping is $15.00
Else if sale amount > $500.00
shipping is $10.00
Else if sale amount > $250.00
shipping is $8.00
Else if sale amount > $0.00
shipping is $5.00
Else
shipping is $0.00
End-If
If shipping is $0.00
Display "Error incorrect input"
Else
Display sale amount and shipping charge
End-If
Step 3: Create a New Project
Create a new project and name it LAB2B. Make sure you close your previous program by clicking File >> Close Solution. Write your code using the Processing Logic in Part B Step 2.
Step 4: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, or by clicking the Save button on the toolbar, or Ctrl + S.
Step 5: Build Solution
To compile the program, click Debug then Build solution (F7). 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 6: 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 7: Capture the Output
Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) Copy your code and paste it into the same MS Word document that contains the screen print of your output. Save the Word Document as Lab02B_LastName_FirstInitial.
0 notes
Link
DEVRY CIS 170 C iLab 1 of 7 Getting Started
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-c-ilab-1-of-7-getting-started
For more classes visit
http://www.cis170entirecourse.com
CIS 170 C iLab 1 of 7 Getting Started
Lab 1 of 7: Getting Started (Your First C++ Programs) Lab Overview - Scenario/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.
In general, this lab will instruct you on:
how to create a project; how to enter and save a program; how to compile and run a program; how to, given a simple problem using input and output, code and test a program that meets the specifications; and how to debug a simple program of any syntax and logic errors.Deliverables
Section
Deliverable
Points
Part A
Step 6: Program Listing and Output
15
Part B
Program Listing and Output
15
Part C
Program Listing and Output
15
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.
Lab:
Part A: Getting Started
Step 1: Start the Application
From the File menu, choose "New Project." Choose “Win32 Console Application.” Enter a name in the name field. Click “Next” and choose the following options: Application Type: "Console Application" Additional options: Check mark “Empty project” and uncheck 8. Click Finish. Your project is now created.
Step 2: How to Add a Source Code File to Your Project (.cpp file)
In the Solution Explorer, right-click on the “Source Files” folder and select "Add" and then "New Item." In the next dialog box, choose C++ file (.cpp), enter a name for your source code file, and press the Add button. Type or copy and paste your code into the newly created source code file. Build the file by pressing F7, and then execute your program by pressing CTRL-F5 (start without debugging) or use the F5 key (Start Debugging).
Step 3: Create a Source Code File
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.
#include
using namespace std;
void main()
{
cout< "john="" doe"=""><endl;="">
cout< "cis170c="" -="" programming="" using="" c++\n";="">
cout< "\n\n\nhello,="" world!\n\n";="">
}
When you execute a program in debug mode (F5), the console screen may appear and disappear
before you have an opportunity to view your output. There are several techniques you can use to
pause the console screen so you can read the output. On the very last line in the main() function:
a. insert the statement: system("pause");
-OR-
b. insert an input statement: cin<myvarable;="">
Step 4: Output
The black screen or console should read:
John Doe
CIS170C - Programming using C++ Hello, World -
Step 5: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, or by clicking the Save button on the toolbar, or Ctrl + S.
Step 6: Build Solution
To compile the program, click Build on the menu bar and then click the BuildSolution or Build LabA option. 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 7: 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 Without Debugging.
Step 8: Capture the Output
Print a picture of your screen output. (Do a print screen and paste this into MS Word.)
Step 9: Print the Source Code
Copy your source code and paste it into the same Word document as your screen print. Save the Word Document as Lab01A_LastName_FirstInitial
Note: Using the Visual Studio editor to compile your programs creates a lot of overhead. These additional files will become important as you create more sophisticated C# projects. Projects can contain one or more source-code files. For this course, you will not have to worry about all the extra files that are created.
End of Part A
Part B: Calculate Total Tickets
Step 1: Create New Project
Now create a new project and name it LAB1B. Make sure you close your previous program by clicking File >> Close Solution.
Step 2: Type in Program
Like before, 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
// ---------------------------------------------------------------
#include
using namespace std;
void main()
{
intchildTkts, adultTkts, totalTkts;
;
;
+ adultTkts;
cout<totaltkts=""><endl;="">
}
Step 3: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, 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 BuildSolution or Build LabB option. 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 Without Debugging.
Step 6: Capture the Output
Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.) 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 Lab01B_LastName_FirstInitial.
End of Part B
Part C: Payroll Program
Step 1: Create a New Project
Create a new project and name it LAB1C. Make sure you close your previous program by clicking File >> Close Solution.
Include a comment box like what you coded in Part B. This can go at the very top of your program.
Step 2: Processing Logic
You need to write a program that calculates and displays the take-home pay for a commissioned sales employee along with all of the deductions.
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
Sample Output from Lab 1: Enter Weekly Sales: 28000
Total Sales: 28000.00 Gross pay (7%): 1960.00
Federal tax paid: 352.80 Social security paid: 117.60 Retirement contribution: 196.00 Total deductions: 666.40 Take home pay: 1293.60 Press any key to continue . . .
Flowchart: (continued on next page)
Pseudo Code:
1. Declare variables 2. Accept Input - weeklySales 3. Calculate Gross Sales * .07 4. Calculate Federal Pay * .18 5. Calculate Social Pay * .06 6. Calculate Pay * .1 7. Calculate Total Tax + Social Security + Retirement 8. Calculate Total Take Home Pay - Total Deductions 9. Display the following on separate lines and format variables with $ and decimal. a. Total Sales Amount: value of weekly sales b. Gross Pay (.07): value of gross pay c. Federal Tax paid (.18): value of federal tax d. Social Security paid (.06): value of social security e. Retirement contribution (.1): value of retirement f. Total Deductions: value of total deductions g. Take Home Pay: value of take home pay
Note: Use SetPrecisions(2) to format the output (see page 98 of the text). The statements should look something like the following:
//include the iomanip header file at the top of the file
#include
//use fixed and setprecision(2) to format the number
//use setw(8) to control the width of the field
//use \t to control the spacing between fields
cout< fixed=""><setprecision(2);="">
cout< "gross="" pay="" (0.07):\t="" $"=""><setw(8)=""><grosspay=""><endl;="">
m
0 notes
Link
DEVRY CIS 170 Entire Course
Check this A+ tutorial guideline at
http://www.cis170entirecourse.com/cis-170/cis-170-entire-course
For more classes visit
http://www.cis170entirecourse.com
CIS 170 Entire Course
CIS 170C iLab 1 of 7 Getting Started
CIS 170 iLab 2 of 7 Decisions
CIS 170C iLab 3 of 7 Looping
CIS 170C iLab 4 of 7 Functions
CIS 170C iLab 5 of 7 Arrays and Strings
CIS 170C iLab 7 of 7 Sequential Files
CIS 170C Lab 6 of 7 Menu-Driven Applications
CIS 170 C Final Exam
0 notes