Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3.2, Problem 6STE
What output will be produced by the following code, when embedded in a complete
int extra = 2;
if (extra < 0)
cout << “small”;
else if (extra = = 0)
cout << “medium”;
else
cout << “large”;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Based on this program, write a flow charts.
Addendum: allow user input.
*/
// set up variables
int sharesPurchased;
double sharesCostPerShare;
double stockBrokerCommission;
//int sharesOnHand;
//double sharesOriginalCostPerShare;
double buyingCost;
//double sellingCost;
double brokerCost;
String input;
// input
input = JOptionPane.showInputDialog("Purchase how many shares? ");
sharesPurchased = Integer.parseInt(input);
input = JOptionPane.showInputDialog("Cost per share? ");
sharesCostPerShare = Double.parseDouble(input);
input = JOptionPane.showInputDialog("Stock broker commission? (ie. .02 for 2%) ");
stockBrokerCommission = Double.parseDouble(input);
// calculate
buyingCost = sharesPurchased * sharesCostPerShare;
brokerCost = sharesPurchased * stockBrokerCommission;
// display purchase
JOptionPane.showMessageDialog(null, "Shares…
options same for each one
Analyze the following code:
int x = 0;int y = ((x < 100) && (x > 0)) ? 1: -1;
The code has syntax error.
y becomes 1 after the code is executed.
y becomes -1 after the code is executed.
The code has run time error.
Chapter 3 Solutions
Problem Solving with C++ (9th Edition)
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Present Value Suppose you want to deposit a certain amount of money into a savings account, and then leave it a...
Starting Out with Java: From Control Structures through Objects (6th Edition)
A_____ is a storage location in memory that is represented by a name. a. mnemonic b. data type c. namespace d. ...
Starting out with Visual C# (4th Edition)
Write a database description for each of the relations shown, using SQL DOL (shorten, abbreviate. or change any...
Modern Database Management
Why are some items within a class designated as private?
Computer Science: An Overview (12th Edition)
What are the advantages in implementing a language with a pure interpreter?
Concepts of Programming Languages (11th Edition)
A(n) _____ is a specialized routine that performs a specific operation and then returns a value.
Starting Out With Visual Basic (7th 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
- 2. Create a program that computes and displays a game character's attack speed at a certain level. Use the formula below. Formula: Current attack speed = Base attack speed * (1 + (Bonus attack speed % * (Level - 1) The variable for level should be of int type. The bonus attack speed % should be converted to decimal (divide by 100) before multiplying by the level. For example, if the user enters 4% for the bonus attack speed, the formula will use 0.04 instead of 4. Round the current attack speed to the nearest two (2) decimal places. Sample Output: Enter the base speed of the attack:0.65 Enter the bonus attack speed %:4 Enter the level:10 The character/s current attack speed is 0.88 ...arrow_forwardlif the following code, what will be the variable "value" equal to when y=2 is being executed: def foo(value) : value = value + 2 def main(): x = 1 foo(x) y = 2 Variable "value" does not exist when y=2 is being executed. 02arrow_forwardThe production of the form A -> B is called Select one: O O O O A. Lambda Production B. Null Production C. Unit Production D. Useless Productionarrow_forward
- int test(int *x, int y){ x=&y; return(*x+y); } int main(void) { int x=1, y=6; test(&y, x); printf("%d %d %d", x, test (&y,x),y); return 0; } 1 2 6arrow_forward5- What is the output for y? int y = 0; for (int i = 0; i< 10; ++i) { y +=i; } cout << y;arrow_forward2) for both triangle and diamond, first display a triangle of requested size, and then if the choice is a diamond, add the bottom part 3) displays the shape We want to create a program that draws a diamond or a triangle with a size that the user selects using a specific character that will be entered at the keyboard. Here are two examples: To write this program, we will assume that we have the following functions: 1) void instructions() // This function describes the program and how it works A triangle of size 4, using *: 2) int menu() // This function will return a choice to the main ; 1) draw triangle, 2) draw diamond, and 3) quit *** ***** ******* 3) draw_shape(int choice) // This function calls on appropriate function depending on the choice to draw a shape A diamond of size 4, using *: 4) int get_size() // This function will return the size of the shape, same function for either of the shapes *** ***** ******* ***** 5) char get_char() // This function will ask users to select a…arrow_forward
- The Nim game. Write a program for a two-player version of the game Nim: a human player will play against the computer. The game is simple: players take turns removing from 1 to 4 sticks from a pile of 13 sticks; the player who picks up the last stick wins the game. Here’s some pseudocode for the Nim game. Start by initializing some variables that will allow you to keep track of the state of the game: One variable should record how many sticks there are left in the pile; initially, this variable must be initialized to 13. There are two players in the game, who take turns. To remember who’s turn is next, use a variable with two states (= values). Say the variable is 1 if the human player is next, and it is 2, if the computer’s turn is next. Pick randomly the player who should start the game. Then, start the main loop of the game: the game should continue for as long as there still are sticks (at least one) to pick. In each repetition of the game loop, one player will play their turn:…arrow_forwardAnnotate following code. def QualityPointCalculator(qualPnts, crdts): if crdts > 0: return qualPnts/crdts return 0def convertGrade(grade): if grade == "A": return 4.00 elif grade == "A-": return 3.70 elif grade == "B+": return 3.30 elif grade == "B": return 3.00 elif grade == "B-": return 2.70 elif grade == "C+": return 2.30 elif grade == "C": return 2.00 elif grade == "C-": return 1.70 elif grade == "D+": return 1.30 elif grade == "D": return 1.00 else: return 0.00 def calcQualPnts(pnts, crdts): return pnts*crdts if __name__ == '__main__': quality_points = [] course_names = [] grades = [] credits = [] final_gpa = 0.0 semester_gpa = 0.0 final_total = 0.0 howMany = 0 print('GRADE & QUALITY NUMERICAL POINTS') choice = input('Would you like to calculate your GPA for a term? Enter Y/N: ') while choice.upper()[0] == 'Y':…arrow_forwardFaster please!arrow_forward
- int i = 10; int j = 4; int k = i / j; int l = j % i; What is k and l?arrow_forwardWhat is the final value of y? int x = 4; 6; int y if (x < 10) { if (y < 5) { y = y + 1; } } else { } y = 7; } else { y = y + 10;arrow_forwardа. int GreaterThan(int no) { if (no > 10) printf("%d is greater than 10", no); else printf("%d is less than 10", no); }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY