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 15STE
What output will be produced by the following code, when embedded in a complete
int firstChoice = 1;
switch (firstChoice + 1)
{
case 1:
cout << “Roast beef\n”;
break;
case 2:
cout << “Roast worms\n”;
break;
case 3:
cout << “Chocolate ice cream\n”;
case 4:
cout << “Onion ice cream\n”;
break;
default:
cout << “Bon appetit!\n”;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
2) 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…
Write a statement that assigns finalValue with the multiplication of userNum1 and userNum2. Ex: If userNum1 is 6 and userNum2 is 2, finalValue is 12.
let userNum1 = 6; // Code tested with values: 6 and 4let userNum2 = 2; // Code tested with values: 2 and -2
let finalValue = 0;
C Language - Write a program that takes in three integers and outputs the largest value. If the input integers are the same, output the integers' value.
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
The article mentions that quantum computers will have tremendous processing power and revolutionize a number of...
Using MIS (10th Edition)
Rewrite the definition of the method writeoutput for the class Undergraduate in Listing 8.4, using getName and ...
Java: An Introduction to Problem Solving and Programming (7th Edition)
Convert the following do-while loop to a while loop: char sure; do cout "Are you sure you want to quit? cin s...
Starting Out with C++ from Control Structures to Objects (9th Edition)
The EventHandler interface specifies a method named . a. register b. onClick c. fire d. handle
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Addition in Boolean algebra is equivalent to the OR function.
Digital Fundamentals (11th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th 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
- Q1: The local Driver's License Office has asked you to write a program that grades the writ- ten portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. A 2. D 3. B 4. B 5. C 6. B 7. A 8. B 9. C 10. D 11. A 12. C 13. D 14. B 15. D 16. C 17. C 18. A 19. D 20. B Your program should store the correct answers shown above in an array. It should ask the user to enter the student's answers for each of the 20 questions, and the answers should be stored in another array. After the student's answers have been entered, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions. Input Validation: Only accept the letters A, B, C, or…arrow_forward9. What is the value of x after the following statements are executed? int x = 5; switch (x) { case 5: } a. 6 b. 7 c. 8 x = x + 2; case 6: x = x + 1; break; default: x = x * 2; break; d. e. 10 16arrow_forwardJAVA:arrow_forward
- Void Do1 (int: &, a. int &b) { a = 5; a = a + b; b = a + 2; } Int main() { Int x = 10; Do1 (x,x); Cout << x << endl; } The output of this program isarrow_forwardEnter student mark : mark If 70>Mark >60 mark = mark + 3 If 80> mark >70 mark = mark+4 C# If 90> mark >80 mark = mark+5 If 100> mark >90 mark = mark+3 Else print print "fail" and "good luck in the next time" int Mark; Console.Write("Please enter student mark: "); Mark= Int32.Parse(Console.ReadLine()); if (Mark 60) Mark = Mark + 3; Console.WriteLine("New Mark ={0}", Mark); Console.ReadKey(); P 3:45arrow_forwardVisual Studio 2019 how to loop this code in c# 8.0 using System; namespace ConsoleApp1{class Program{static void Main(string[] args){double cm, meter, kilometer, mili;//primero se declaran las variablesConsole.WriteLine("Introduzca los kilómetros");kilometer = Convert.ToInt32(Console.ReadLine());Console.WriteLine("Introduzca los metros");meter = Convert.ToInt32(Console.ReadLine());Console.WriteLine("Introduzca los centimetros");cm = Convert.ToInt32(Console.ReadLine());Console.WriteLine("Introduzca los milímetros");mili = Convert.ToInt32(Console.ReadLine());Console.WriteLine("Seleccione una opción");Console.WriteLine("\ta-Conversion de kilometros a: ");Console.WriteLine("\tb-Conversion de metros a: ");Console.WriteLine("\tc-Conversion de centimetros a: ");Console.WriteLine("\td-Conversion de milimetros a: ");Console.Write("¿Tú opción? ");switch (Console.ReadLine()){case "a":Console.WriteLine("kilómetro a metro:" + (meter = kilometer * 1000.0));Console.WriteLine("kilómetro a…arrow_forward
- A mail-order house sells five products whose retail prices are as follows: Product 1, $2.98; product 2, $4.50; prod- uct 3, $9.98; product 4, $4.49 and product 5, $6.87. Write an application that reads a series of pairs of numbers as follows: a) product number b) quantity sold Your program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the pro- gram should stop looping and display the final results.arrow_forward#include <stdio.h>#include <stdlib.h> //declaring variables globally to calculate coinsint cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0; //calculate change//pass change variable by addressvoid calculateChange(int* change) {//calculate change only if change is positiveif(*change > 0) {if(*change >= 50) {*change -= 50;cent50++;}else if(*change >= 20) {*change -= 20;cent20++;}else if(*change >= 10) {*change -= 10;cent10++;}else if(*change >= 05) {*change -= 05;cent05++;}//call calculateChange recursively calculateChange(change);}} // function to display the cents valuesvoid printChange() { if(cent50)printf("\n50 Cents : %d coins", cent50);if(cent20)printf("\n20 Cents : %d coins", cent20);if(cent10)printf("\n10 Cents : %d coins", cent10);if(cent05)printf("\n05 Cents : %d coins", cent05);//reset all cent variables with 0cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0; } //take change input from user//change variable passed addressvoid TakeChange(int*…arrow_forwardC - Write a program that takes a first name as the input, and outputs a welcome message to that name.arrow_forward
- Assume the following code segment is in a complete program: void SomeFunction( int&, int); int main() { int x; int y; x = 5; y = 7; SomeFunction(x, y); cout << x << y << endl; return 0; } void SomeFunction( int& a, int b ) { a = a * 2; b = b + a; } What is the output of the program? Select one: a. 14 5 b. 10 7 c. 17 7 d. 5 19 e. 10 17arrow_forwardTask 2: Conditional Statements (Java) ‘Taste Buds’ Ice cream shop provides a menu to customers with ice cream flavours and prices. The customer selects a flavour from the menu at a time until ‘S’ or ‘s’ is entered to stop: Write an application in Java that reads customer choices, calculates the subtotal and total cost of an order using appropriate conditional statements; Output the summary of the task as follows: Welcome to Taste Buds Ice Creams!! Select from the following menu: V: Vanilla: 1.000 OMR S: Strawberry: 1.500 OMR M: Mango: 2.000 OMR C: Chocolate: 2.500 OMR Sample Output: Order a flavour or enter ‘S’ to stop >> V: Vanilla ordered, Subtotal: 1.000 OMR Order another flavour or enter ‘S’ to stop >> M, Mango ordered, Subtotal: 3.000 OMR Order another flavour or enter ‘S’ to stop >> s Total Order cost is 3.000 OMRarrow_forwardCreate a flowchart for this programarrow_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
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY