COMP 220 COMP220 COMP/220 Week 1 Lab Two-Dimensional Arrays – Southern Alberta Institute of Technolo

Page 1

COMP 220 COMP220 COMP/220 Week 1 Lab Two-Dimensional Arrays – Southern Alberta Institute of Technology (SAIT)

DOWNLOAD SOLUTION https://www.solvedcollegepapers.com/product/comp-220-comp220-comp-220-ait/ This lab requires you to design and implement a C++ program to simulate a game of Blackjack between two to four players. Your program must incorporate a two-dimensional array to represent the suit and the value of each card dealt to a player, keep track of which cards have been dealt to which player, and use a random-number generator to pick each card to be dealt to a player. Deliverables 1. Submit a single Notepad file containing the source code for Lab 1 to the Dropbox for Week 1. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, Y ourLastName_Lab1.txt. Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes. 2. Submit a lab report (a Word document) Category: Assignments Help Experts Tags: COMP 220 COMP220 COMP/220 Computer Fundamentals - Southern Alberta Institute of Technology (SAIT), COMP 220 Week 1 Lab TwoDimensional Arrays, COMP 220 Week 2 Lab Classes Objects and Encapsulation, COMP 220 Week 3 Lab Inheritance, COMP 220 Week 4 Lab Composition, COMP 220 Week 5 Lab Pointers and Pointer Operations, COMP 220 Week 6 Lab Overloaded Operators, COMP 220 Week 7 Lab Polymorphism, COMP 220comp220 lab 7, comp220 week 7, comp220 week 7 ilab 

Description

Description


COMP 220 Week 1 Lab Two-Dimensional Arrays – Southern Alberta Institute of Technology (SAIT) This lab requires you to design and implement a C++ program to simulate a game of Blackjack between two to four players. Your program must incorporate a two-dimensional array to represent the suit and the value of each card dealt to a player, keep track of which cards have been dealt to which player, and use a random-number generator to pick each card to be dealt to a player. Deliverables 1. Submit a single Notepad file containing the source code for Lab 1 to the Dropbox for Week 1. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, Y ourLastName_Lab1.txt. Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes. 2. Submit a lab report (a Word document) containing the following information to the Dropbox for Week 1. o Include your name and the exercise number. o Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output. o Test Plan: Include a brief description of the method you used to confirm that your program worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and actual results. o Summary and Conclusions: Write a statement summarizing your predicted and actual output, and identify and explain any differences. For your conclusions, write at least one nontrivial paragraph that explains, in detail, either a significant problem you had and how you solved it or, if you had no significant problems, something you learned by doing the exercise. o Answers to Lab Questions: Answer any and all of the lab questions included in the lab steps. Each lab exercise should have a separate section in the lab-report document. iLAB STEPS STEP 1: Starting Visual Studio Create a new Visual Studio empty project, and add one C++ source code file. STEP 2: Coding Enter the following source, which will set up the 2D array and the recommended variable declarations. It is up to the student to design and implement the remainder of the program code.


1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2

// Programmer: (put your name here) // Course: COMP220 // Assignment: Two-Dimensional Arrays // Description: The program will use a 2D array and a random-number // generation to play Blackjack and keep track of a playing-card deck. // Input: User data entry and a playing-card deck represented as a two- // dimensional array // Output: A screen display showing the current card hands of each player // and the dealer, their score, win and lose status, and a final representation // of the card deck after the game is over #include<iostream> #include<iomanip> #include<windows.h> using namespace std; void main (void) { bool bPlayerDraw[5]; //Boolean to determine if player holds (F) //or draws card (T) char cPlay = 'N'; //Character variable for play game input char cCardDeck[4][13]; //Character array representing the card deck int iCard; //0 = 2 card //1 = 3 card //2 = 4 card //3 = 5 card //4 = 6 card //5 = 7 card //6 = 8 card //7 = 9 card //8 = 10 card //9 = jack card //10 = queen card //11 = king card //12 = ace card int iNumberOfDraws = 0; //Number of rounds of card draws int iSuit; //Suit array index //0 = diamonds //1 = hearts //2 = clubs //3 = spades // ASCII character display reference for display card suit symbols //3 = heart symbol //4 = diamond symbol //5 = club symbol //6 = spade symbol int iNumberOfPlayers = 0;//Number of players in current game int iPlayerCount[5]; //Integer array to holder each player's count //iPlayer[0] is always the dealer int iHighestCount = 0; //Highest count for a single game int k, m; //integer loop counters srand(GetTickCount()); //Seed the randomnumber generator //Main game loop //Enter your code here...


8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 A sample output of the program is below: Welcome to Honest Sam’s Blackjack Table Glad to have you back! Enter the number of players in the game. There must be at least one player but no more than four. Number of players: 3 [table] , Card 1 , Card 2 , Card 3 , Total , Stats Dealer , J♦ , 10♦ , 9♣ , 29 , Lose Player 1, K♣ , 2♠ , 5♥ , 17 , Lose Player 2 , J♣ , Q♥ , 10♥ , 30 , Lose Player 3 , 3♦ , 8♣ , K♦ , 21 , Win! [/table]


STEP 3: Program Specifications 1. There is always a dealer in the game. The dealer draws 3 cards. 2. There must be at least one other player (you) and up to a maximum of four other players (all played by you). o Each player will draw 3 cards. o All the cards for each player, including the first card dealt, are displayed, along with the suit symbol: spades ♠, clubs ♣, hearts ♥, or diamonds ♦. 3. Each game will start with a new, 52-card deck, which is modeled on a real deck of cards. 4. The card deck has 52 cards with no jokers. 5. The card deck is represented by a two-dimensional array of data-type character, where the first dimension represents the suit and the second dimension represents the card in the suit, such as the following. char CardDeck[4][13]; 6. At the start of each game, each element of the two-dimensional array is initialized to a value of ” “, or the “space” character. 7. The deck has four suits, represented by the following dimension indices. o 0 = diamonds o 1 = hearts o 2 = clubs o 3 = spades 8. Each suit has 13 cards: 2, 3, 4, 5, 6, 7, 8, 9 ,10, jack, queen, king, and ace. 9. Each card in a suit is represented by the following dimension indices. o 0 = the 2 card o 1 = the 3 card o 2 = the 4 card o 3 = the 5 card o 4 = the 6 card o 5 = the 7 card o 6 = the 8 card o 7 = the 9 card o 8 = the 10 card o 9 = the jack o 10 = the queen o 11 = the king o 12 = the ace 10. All the number cards are worth their face value (i.e., a 3 of diamonds is worth 3). 11. All face cards are worth 10. 12. An ace is worth either 1 or 11. Your final-score calculation must be able to handle this correctly for both the dealer and each player. 13. A random-number generator must be used to select the suit and the card in the suit. Once a card and suit are selected, the program should check if the value of that array element is a “space.” o If the array element = “space,” set the element equal to an integer, identifying the dealer or the player.  0 = dealer


1 = player 1 2 = player 2 3 = player 3 4 = player 4 o If the array element ! = “space,” then the random-number and card- checking process should repeat until a “card” or an array element is selected that is = “space.” 14. Once a card is drawn during a game, it cannot be drawn again. 15. If the user inputs to play the game, the next decision should be 1, 2, 3, or 4 players. 16. The game ends when each player has 3 cards. 17. The display should show each player’s (and the dealer’s) hand and update the display after each round of card draws. 18. At the end of a game, the an updated balance.    

Download Full Course Solution: BUS 303 Human Resource Management Entire Course Help https://www.solvedcollegepapers.com/product/bus-303-human-resource-managemententire-course-help/ BUS 303 Human Resource Management Entire Course Help> Ashford University Bus 303 Human Resource Management Week 1 Quiz 1.docx Bus 303 Human Resource Management Week 1 Quiz 1.docx BUS 303 – Fall 2018 Bus 303 Human Resource Management Week 1 Quiz 1.docx 5 pages BUS 303 Week 1 quiz.docx Download Full Course Solution: POL 255-Entire course Help: Ashford University https://www.solvedcollegepapers.com/product/pol-255-entire-course-help-ashforduniversity/ POL 255 Entire Course NEW POL 255 Week 1 Assignment Theory, Arms Races, and the Prisoner’s Dilemma NEW (2 Sets) POL 255 Week 1 Discussion IR Theories Strengths and Weaknesses NEW POL 255 Week 1 Quiz NEW POL 255 Week 2 Assignment Levels of Analysis and the Crisis in Syria NEW POL 255 Week 2 Discussion Communicating National Interests NEW


POL 255 Week 2 Quiz NEW POL 255 Week 3 Assignment Moral and Ethical Dilemmas from America’s Use of Drones NEW POL 255 Week 3 Discussion The Contemporary International System NEW POL 255 Week 3 Quiz NEW POL 255 Week 4 Assignment Easter Island Full of Mystery NEW POL 255 Week 4 DQ NEW POL 255 Week 5 DQ NEW

Download Full Course Solution: PSY 215 PSY215 PSY/215 Module Two Milestone. Shaina Dado.docx https://www.solvedcollegepapers.com/product/psy-215-psy215-psy-215-dado/ According to the findings of the Pew Research study, there are several potential costs and benefits that result from frequent exposure to social media. oDescribe one psychological benefitof frequent social media use. Social media usage can have several effects on us whether it be bad or beneficial. We use social media as a way to connect with others. Living alone after moving to a new place can be overwhelming and can make you feel lonely. Being able to connect with your loved ones, old colleagues and family through social media can help you rememberthat you aren’t alone. Seeing how others are doing through their posted photos or even through what they post can make you feel like you aren’t missing out on much. oDescribe one psychological costof frequent social media use. As there are positives to social media use, there are some costs that come with it. The frequent need for attention can become a cost when it comes to social media. Download Full Course Solution: [New Answers]-Full course CMIT-200: Relational Database Design and SQL https://www.solvedcollegepapers.com/product/cmit-200-relational-database-design-andsql/ Course Description and Prerequisites A relational database management system (RDBMS) is the heart of most modern information systems. This is a survey course in relational database design, development, and implementation. The course covers key concepts of database design using entity relationship diagrams (ERDs), normalization, and functional dependence. Logical and physical schemas and the use of Structured Query Language (SQL) to query data will be studied in depth. Student learning is reinforced through discussions and hands-on laboratory assignments. Students will complete a relational database project by using a relational database management system.


This course is intended for anyone who is involved in designing, developing, or implementing relational database management systems (e.g., users, IT managers, technical staff, and other IT team members). Prerequisite: CMIT-135 Student-Centered Learning Outcomes      

Design a relational database using entity relationship diagrams and SQL Normalize relational database tables through third normal form (3NF) Differentiate between conceptual, logical, and physical database designs Specify different types of relationships between database entities and objects Physically create databases using SQL Data Definition Language (DDL) Query databases using SQL Data Manipulation Language (DML)


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.