Problem Solving with C++ - MyProgrammingLab
10th Edition
ISBN: 9780134522418
Author: SAVITCH
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3.2, Problem 14STE
Given the following declaration and output statement, assume that this has been embedded in a correct
enum Direction { N = 5, S = 7, E = 1, W };
// ...
cout << W << “ ” << E << “ ” << S << “ ” N << endl;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume the following declarations and initializations (MIN, MAX, num) are made justbefore each sub-question 1 to 15 (i.e., assume these initializations are in effect at thebeginning of each problem). What is the output each code?
final int MIN = 10, MAX = 20;int num = 15;
8. do {num = num + 1;if (num * 2 > MAX + num)System.out.print(num + “ “);} while (num <= MAX);
9. for (int value = 0; value >= 7; value++)System.out.print(value + “ “);
10. for (int value = 7; value < 0; value--)System.out.print(value + “ “);
11. for (int value = 1; value >= 20; value+=4)System.out.print(value + “ “);
Given the following code segment:
a) What will be the output (line 9) if operands are evaluated left to right inour programming language?b) Answer the same question if operands are evaluated right to left.
I have an assignment that needs to be turn in before monday, here's the question:
Two people play the game of Count 21 by taking turns entering a 1, 2, or 3, which is added to a running total. The player who adds the value that makes the total reach or exceed 21 loses the game. Create a game of Count 21 in which a player competes against the computer, and program a strategy that always allows the computer to win. On any turn, if the player enters a value other than 1, 2, or 3, force the player to reenter the value. Save the game as Count21.java.
Here's the code that I'm working on:
import java.util.Scanner;public class Count21 {public static void main(String[] args) {// Scanner object to get user inputScanner scanner = new Scanner(System.in);// Stores the running total.
//Displays a welcome for the user
public void promptEnterKey(){System.out.println("Welcome to Count21! \n");System.out.println("Press \"ENTER\" to continue...");Scanner scanner = new…
Chapter 3 Solutions
Problem Solving with C++ - MyProgrammingLab
Ch. 3.1 - Determine the value, true or false, of each of the...Ch. 3.1 - Name two kinds of statements in C++ that alter the...Ch. 3.1 - In college algebra we see numeric intervals given...Ch. 3.1 - Prob. 4STECh. 3.2 - What output will be produced by the following...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 9...
Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - Write a multiway if-else statement that classifies...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - Prob. 19STECh. 3.2 - Though we urge you not to program using this...Ch. 3.3 - Prob. 21STECh. 3.3 - Prob. 22STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 25STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 27STECh. 3.3 - For each of the following situations, tell which...Ch. 3.3 - Rewrite the following loops as for loops. a.int i...Ch. 3.3 - What is the output of this loop? Identify the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What does a break statement do? Where is it legal...Ch. 3.4 - Write a loop that will write the word Hello to the...Ch. 3.4 - Write a loop that will read in a list of even...Ch. 3.4 - Prob. 38STECh. 3.4 - Prob. 39STECh. 3.4 - What is an off-by-one loop error?Ch. 3.4 - You have a fence that is to be 100 meters long....Ch. 3 - Write a program to score the paper-rock-scissor...Ch. 3 - Write a program to compute the interest due, total...Ch. 3 - Write an astrology program. The user types in a...Ch. 3 - Horoscope Signs of the same Element are most...Ch. 3 - Write a program that finds and prints all of the...Ch. 3 - Buoyancy is the ability of an object to float....Ch. 3 - Write a program that finds the temperature that is...Ch. 3 - Write a program that computes the cost of a...Ch. 3 - (This Project requires that you know some basic...Ch. 3 - Write a program that accepts a year written as a...Ch. 3 - Write a program that scores a blackjack hand. In...Ch. 3 - Interest on a loan is paid on a declining balance,...Ch. 3 - The Fibonacci numbers F are defined as follows. F...Ch. 3 - The value ex can be approximated by the sum 1 + x...Ch. 3 - Prob. 8PPCh. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 13 from Chapter 2 but...Ch. 3 - The keypad on your oven is used to enter the...Ch. 3 - The game of 23 is a two-player game that begins...Ch. 3 - Holy digits Batman! The Riddler is planning his...Ch. 3 - You have an augmented reality game in which you...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Define each of the following terms: entity type entity-relationship model entity instance Attribute relationshi...
Modern Database Management
What would be the hexadecimal representation of the largest memory address in a memory consisting of 4MB if eac...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Sales Report Brewster's Used Cars, Inc. employs several salespeople. Brewster, the owner of the company, has pr...
Starting Out with Programming Logic and Design (4th Edition)
This is the last index in a string. a. 1 b. 99 c. 0 d. The size of the string minus one
Starting Out with Python (3rd Edition)
What are the bits in a binary system?
Digital Fundamentals (11th Edition)
Which of the following activities require real-time processing? a. Printing mailing labels b. Playing a compute...
Computer Science: An Overview (12th Edition)
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
- Need a help with this programs for each of the following problem statements: - use of comment statements- use of descriptive variable names 1. (gcount) A program that will accept any number of grades foran exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1for a D, and 0 for an F. After all grades have been entered, allow theuser to enter -1 to exit. Output the number of grades in each category. - correct use of array of counters - correct use of loop - correct outputarrow_forwardWrite a program that produces the following output: ********************************** * Programming Assignment 1 * * Computer Programming I * * Author: ??? * * Due Date: Thursday, Jan. 24 * ********************************arrow_forwardI need help trying to write a program that simulates the condition you may find at a traffic light. The program should prompt the user to enter a value of G, Y, or R that corresponds to a green, yellow, or red light. However, in the case of a yellow light, the program should prompt the user to check for a police presence by entering a value of Y or N for yes or no. If there are no police in sight then proceed through the light, otherwise come to a complete stop. This program that I need help on uses an if-else statement. I use java eclipse. Thank you so mucharrow_forward
- Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order.def swap_values(user_val1, user_val2) I get all tests passed except one.: the one in the bold. It puts parentheses around the answer instead of what they want for output. 0 / 2 Output differs. See highlights below. Input 4 5 Your output (5, 4) Expected output 5 4 2: Unit testkeyboard_arrow_up 2 / 2 swap_values(-1, 10) Your output swap_values(-1, 10) correctly returned 10 -1 3: Unit testkeyboard_arrow_up 3 / 3 swap_values(9, 0) Your output swap_values(9, 0) correctly returned 0 9 4: Unit testkeyboard_arrow_up 3 / 3 swap_values(11, 11) Your output swap_values(11, 11) correctly returned 11 11arrow_forwardWrite a program that does temperature converter :\n", "- The user will enter if he wants the result in Celsius or in Fahrenheit. Use the input function to read this option. \n", "- Ask the user the value of the temperature he wants to convert. Use the input function to read this value and convert accordingly.\n", "- If the user wants the temperature in Fahrenheit compute: $ Fahrenheit = Celsius*5/9+32$.\n", "- If the user wants the Celsius compute as follows: $ C = (F-32)*5/9 $.\n"arrow_forward"Write a program that computes the amount of calories burned when you run. Your program should ask for the duration of the run in minutes the speed of the run in mph and the weight in pounds. Computes the amount of calories burned and prints it. The calories/minute of run burned is computed using the expression below:\n", "\n", "$$????????/??????=(???∗????ℎ?∗1.6)/200$$\n", " \n", "Use a function to compute the value of MET as presented in the table below.\n", "\n", "| Speed (mph) | MET |\n", "|--------------|---------|\n", "| 5 or less | 8.3 |\n", "| 6 | 9.8 |\n", "| 7 | 11.0 |\n", "| 8 | 11.8 |\n", "| 9 | 12.8 |\n", "| 10 | 14.5 |\n", "| 12 or more | 19.0 |\n", "\n", "For values in between use the largest MET. Test your code with the values:\n", "```\n", "150 lbs, 6.5 mph and 45 minutes ==> 594.0 calories\n", "200 lbs, 9.8 mph and 30 minutes ==> 696.0 calories\n",arrow_forward
- What is the output assuming dynamic scoping and static scoping! Give answers for both dynamic and static! #include <iostream> using namespace std; int total = 5; int c = 3; int fun1(int); int fun2(int); int main() { int x = 2; int y = 8; cout << " variables x y and c have values: " << x <<" " << y << " " << c << endl; cout << "main: fun1(x) = " << fun1(x) << endl; cout << " After Call to fun1(x) variables x y and c have values: " << x <<" " << y << " " << c << endl; return 0; } int fun1(int a) { int b = 6; int c = 3; b = total + c + a; cout << "in fun1: b= " << b << endl; cout << "in fun 1 after call to fun2(total) the return value is " << fun2(total) << endl; return (b); } int fun2(int w) { c = c * 2; total = total + w + c; cout << "in fun2: total= " << total << endl; return(c); }arrow_forwardWrite a code using C++ for the given prompt: A contractor orders, say, 30 cubic yards of premixed concrete to construct a patio that is to be, say, four inches thick. The length of the patio is to be, say, twice the width. Write a program that prompts the user to specify: The amount of premixed concrete (in cubic yards) ordered The thickness of the patio (in inches) The ratio of length and width Ex. If the ratio is 3 to 2, have the program accept a 3 then a 2. Then compute the ratio using these numbers The program then outputs: The length and width of the patio (in feet). (1 cubic yard = 27 cubic feet.) To calculate the width, you will need to: Find the total cubic feet of the concrete Divide the total cubic feet of concrete by the result of the length to width ratio multiplied by the thickness of the patio, over 12 (inches in a foot) Square root the answer To find the square root of a decimal number, include the header file cmath using the statement #include <cmath>,…arrow_forwardWrite a set of C program statements that allow a user to enter timings for a traffic light until all entered values are valid. Timing values to be entered for the number of seconds the light is red, green and orange are referred to as redTime, greenTime and orange Time respectively. Validity rules for entered timings are as follows: redTime must not be less than the sum of the greenTime and orange Time. orange Time must not be less than five seconds greenTime must be greater than 4 multiplied by the orange Time If timings are valid, the program should output "Timings are valid", and exit. If timings are not valid, the program should output "Invalid timings: Please re-enter", and accept a new set of values.arrow_forward
- The output of the following program has to be as below: Output: 1. Parent process ID : 02. Child process ID: ....3. Grand Child process ID: ...4. Grand Child process ID: .... 5. Grand Child process ID: ... But when I run the code, the Grand Child processes are not displaying in sequential order as shown in the output. I am trying to write a C program such that the parent process will create one child process and 3 grandchild processes and print their IDs. The Grand Child processes must appear in order of 3,4 and 5. I am attaching my code below. Please tell me what should I change in the code to get the desired output. My Code: #include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <sys/wait.h>int main() {printf("1. Parent process ID: %d\n", getpid());pid_t child;child = fork();if (child<0) {printf("error");}else if (child==0) {printf("2. Child process ID: %d\n", getpid());for (int i=3; i<=5; i++) {pid_t grandchild = fork();if…arrow_forwardplease provide the answers to the points in this variable trace Trace through the program below. Indicate value of each of the variables or parameters at the indicated points in the program. Enter 'U' if the variable or parameter is undefined or does not exist at that point. #include <iostream.h>void test (int, int &);int y;void main (void){int x;x = 5; y = 6; // point #1 test (x, y); // point #3}void test (int a, int &b){int c; y = 1; a = 3; b = 9; c = 5; // point #2} Point #1, Variable x Point #1, Variable y Point #1, Variable a Point #1, Variable b Point #1, Variable c Point #2, Variable x Point #2, Variable y Point #2, Variable a Point #2, Variable b Point #2, Variable c Point #3, Variable x Point #3, Variable y Point #3, Variable a Point #3, Variable b Point #3, Variable carrow_forwardThe steelwork.py program, given below, creates three types of steel objects. Carbon steel (Steel) is made of carbon and iron, alloy steel (AlloySteel) contains chromium in addition to carbon and iron. Stainless steel (StainlessSteel) contains nickel and a higher proportion of chromium. Write the missing code, in the designated locations (#TODO), in order for the program execution to yield the following output: ['Steel01', 0.6, 91] ['ALSteel02', 0.6, 91, 1] ['SSteel02', 0.6, 91, 11, 2]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
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License