Programming and Problem Solving With C++
6th Edition
ISBN: 9781449694265
Author: Nell Dale
Publisher: Jones & Bartlett Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 2, Problem 1PSCS
Program Plan Intro
To modify: the program so as to print chessboard using symbol # instead of *.
Expert Solution & Answer
Explanation of Solution
To modify the chessboard program provided in the problem case study change the value of string constant BLACK with "########" instead of "&******"
Following is the modified program(changes are highlighted in grey):
//Add code from textbook here // . // . // . //One row of the dark square made up of eight asterisks (*) conststring BLACK = "########"; //Add code from textbook here // . // . // . Sample output: ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ######## ########
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Python Language:
Word Sleuth Program
Computer Engineering lab
Language: Python with Turtle
Write a program that will have Turtle draw a hexagon.
• You should:
1. Have hexagon sides that are 50 pixels long
2. Use a for loop
• Hint: Figure out how much Turtle will need to turn after drawing each side of the shape to add up to the total 360 degrees.
Chapter 2 Solutions
Programming and Problem Solving With C++
Ch. 2 - Prob. 1PSCSCh. 2 - Prob. 1EPECh. 2 - Prob. 2EPECh. 2 - Prob. 3EPECh. 2 - Prob. 4EPECh. 2 - Prob. 5EPECh. 2 - Prob. 6EPECh. 2 - Prob. 7EPECh. 2 - Prob. 8EPECh. 2 - Prob. 9EPE
Ch. 2 - Prob. 10EPECh. 2 - Prob. 11EPECh. 2 - Prob. 12EPECh. 2 - Prob. 13EPECh. 2 - Prob. 14EPECh. 2 - Prob. 15EPECh. 2 - Prob. 16EPECh. 2 - Prob. 17EPECh. 2 - Prob. 18EPECh. 2 - Prob. 19EPECh. 2 - Prob. 1PWECh. 2 - Prob. 2PWECh. 2 - Prob. 3PWECh. 2 - Prob. 4PWECh. 2 - Prob. 5PWECh. 2 - Prob. 6PWECh. 2 - Prob. 7PWECh. 2 - Prob. 8PWECh. 2 - Prob. 9PWECh. 2 - Prob. 10PWECh. 2 - Prob. 1PPCh. 2 - Prob. 2PPCh. 2 - Prob. 3PPCh. 2 - Prob. 4PPCh. 2 - Prob. 1CSFCh. 2 - Prob. 2CSFCh. 2 - Prob. 3CSFCh. 2 - Prob. 4CSFCh. 2 - Prob. 5CSFCh. 2 - Prob. 6CSF
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Simulation) Write a program to simulate the roll of two dice. If the total of the two dice is 7 or 11, you win; otherwise, you lose. Embellish this program as much as you like, with betting, different odds, different combinations for win or lose, stopping play when you have no money left or reach the house limit, displaying the dice, and so forth. (Hint: Calculate the dots showing on each die with the expression dots=(int)(6.0randomnumber+1), where the random number is between 0 and 1.)arrow_forwardPython programming: A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN B LEFT B RIGHT 2 i The numbers after the direction are steps. Please write a program to compute the distance from current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer. Example: If the following tuples are given as input to the program: UP 5 DOWN 3 LEFT 3 RIGHT 2 Then, the output of the program should be: 2 Hints: In case of input data being supplied to the question, it should be assumed to be a console input.arrow_forwardC Programming Language Task: Pascal's Triangle Write a program to print Pascal's triangle. In Pascal's triangle Each number is the sum of the two numbers above it. You may assume the maximum height for this task is 20. Print each character with 5 spaces of padding. e.g.printf("%5d", variable) 1 1 1 1 2 1 133 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1arrow_forward
- Python Turtle Graphics Draw a spiral diagram using Python turtle package program follows 3 steps: Import the turtle module Create a turtle to control. Draw around using the turtle methods. You should consider the following points in your solution: The shapes should be drawn with the shown colors Yellow and white for the square-like shapes. Blue for the background. The prompt should have a turtle shape. The number of iterations should be 300 You should use only one loop. The number of the yellow color lines should be 200. The final shape of the output should be as shown in the picture attached. Make sure to set properly the starting position (x & y) of your drawing, to maintain the required diagram. video on youtube: https://www.youtube.com/watch?v=ZqoJD2RMu1Iarrow_forwardplease code in python You place a pawn at the top left corner of an n-by-n chess board, labeled (0,0). For each move, you have a choice: move the pawn down a single space, or move the pawn down one space and right one space. That is, if the pawn is at position (i,j), you can move the pawn to (i+1,j) or (i+1, j+1). Ask the user for the size of a chessboard, n (integer). Find the number of different paths starting from (0,0) that the pawn could take to reach each position on the chess board. For example, there are two different paths the pawn can take to reach (2,1). Look at the diagrams below to convince yourself of this. You can see the four paths that you can take by move 2. Start -> Move 1 -> Move 2 (0,0) -> (1,0) -> (2,1) (0,0) -> (1,0) -> (2,0) (0,0) -> (1,1) -> (2,1) (0,0) -> (1,1) -> (2,2) Print the board with the number of ways to reach each square labeled as shown below. For example: Enter a board size: 4 1 0 0 0 1 1 0 0 1 2 1 0 1 3 3 1arrow_forwardTranscribed Image Text Python Development Lab In Merworld there exists 2 coins of different denominations types 5-peso coins and 10- peso coins, both having two faces with image of – Elon Musk and a dog. You are assigned a task to find out the number of ways to arrange these coins so that their sum is N pesos. Arrangement should be done in such a way that the first coin in the arrangement should always have Elon Musk image up. Other coins could have any image. Input Output 1 60 5 LOarrow_forward
- 4. Area of a Rectangle • Write a program that compares the area of two rectangles. You can do this several ways. one way is to add the length and width of each rectangle to get it's area and then compare the two areas together. • The program should ask for the length and width of two rectangles and then tell the user which rectangle has the greater area, or if the areas are the same. • The area of a rectangle is the rectangle's length times its width. Name the source code file yourName HW4.py. • Test and run the program. Capture the output console and save it as an image file named yourName HW4 output.jpg. • Submit the py and the image files through Canvas. Note: Sample output below: Fast l: Code-Tracing Output in comenta Vart 21 Days of the Weekarrow_forwardArchery Scorer. Write a program that draws an archery target (see Pro-gramming Exercise 2 from Chapter 4) and allows the user to click five times to represent arrows shot at the target. Using five-band scoring, abulls-eye (yellow) is worth 9 points and each successive ring is worth 2fewer points down to 1 for white. The program should output a score foreach click and keep track of a running sum for the entire series.arrow_forwardSlove by pythonarrow_forward
- Problem: A small company needs an interactive program to compute an employee’s paycheck. The payroll clerk will initially input the data, and given the input data, an employee's wage for the week should be displayed on the screen for the payroll check. The data for the employee includes the employee's hourly pay rate and the number of hours worked that week. Wage is equal to the employee's pay rate times the number of hours worked (up to 40 hours). If the employee worked more than 40 hours, wage is equal to the employee's pay rate times 40 hours plus 1½ times the employee's pay rate times the number of hours worked above 40. Instructions: Match the action at the left-side with the correct step number at the right-side (the attached picture). Note that it may be possible to group more than one related actions in the same logical step / process without altering the essence of the algorithm. In the program flow, input and checking of hourly pay rate should come before that of the number…arrow_forwardWord Sleuth Puzzle Programarrow_forwardI have an array of the first 50 Fibonacci numbers in the picture. Your program should ask the user for a number between 5 and 21. Using that input as a location in the array, with that location and the next three locations (for example base, base+1, base+2 and base+3) you will multiply the outer values, base and base+3, (the first and last of the four). Do the same for the inner values (base+1 and base+2 multiplied) and then double that value. These two values form the two sides of a right triangle. Now find the hypotenuse. Remember the Pythagorean theorem, which says a2 + b2 = c2. Our two sides are a and b, so we square each of them (remember a * a = a2, so just multiply each value by itself) and add them together. That gives you c2. Now all you need do is take the square root of that sum. Given that the sqrt method normally returns a floating-point value (a double), we must force it to return a long integer for us in this case, so use the following line (with your own…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY