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 17STE
What would be the output in Self-Test Exercise 15 if the first line were changed to the following?
int firstChoice = 2;
15. 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
Part 2 - OddOrEven ClassIn bluej. Write a program that prompts the user to enter an integer. The program should display “The input is odd" to the screen if the input is odd and displays “The input is even" to the screen if the input is even. Hint: Consider using the mod (%) operator.
4
Write an if-else statement to output "Exceeds capacity" if the value of roomCapacity is greater than 161. Otherwise, output
"Does not exceed capacity". End with a newline.
Ex: If the input is 163, then the output is:
Exceeds capacity
1 import java.util.Scanner;
3 public class Relational {
4 public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int roomCapacity;
L23456789
5
11
10
11
12 }
13 }
roomCapacity = scnr.nextInt ();
/* Your code goes here */
2
C - Write a program that takes a first name as the input, and outputs a welcome message to that name.
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
Cookie Calories A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 ...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
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)
A __________ structure provides one alternative path of execution. a. sequence b. single-alternative decision c...
Starting out with Visual C# (4th Edition)
Repair Bill Suppose automobile repair customers are billed at the rate of per hour for labor. Also, suppose co...
Introduction To Programming Using Visual Basic (11th 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
- The following PThreads code is written for book reservation in a library. Each student checks if the book is free. If it was free they will reserve it with their own ID and the book becomes unavailable to the rest. a. Can you identify the problem with this code? Explain the condition that the code may fail. b. Rewrite the code (just a few lines of code) to solve the problem. //PThreads code here if (book.state==free) ( book.state%-reserved; book.borrower%=MyID;arrow_forwardWrite a tester program that counts and displays the number of iterations of the following loop: while problemSize > 0:problemSize = problemSize // 2 After you have write the code. Run the program you created using problem sizes of 1000, 2000, 4000, 10,000, and 100,000. As the problem size doubles or increases by a factor of 10, what happens to the number of iterations?arrow_forwardAssign Barbecue's data member numberOfCalories with a value read from input. Then, assign Ham and Cheese's data member numberOfCalories with another value read from input. Input will contain two integer numbers. Only the *your code goes here can be affected, the rest of the program cannot be changed. Program below: ----------------------------#include <iostream>#include <vector>#include <string>using namespace std; struct PizzaInfo {string pizzaName;int numberOfCalories;}; int main() {vector<PizzaInfo> availablePizzas(2); availablePizzas.at(0).pizzaName = "Barbecue";availablePizzas.at(1).pizzaName = "Ham and Cheese"; /* Your code goes here */ cout << "A " << availablePizzas.at(0).pizzaName << " slice contains " << availablePizzas.at(0).numberOfCalories << " calories." << endl;cout << "A " << availablePizzas.at(1).pizzaName << " slice contains " << availablePizzas.at(1).numberOfCalories << "…arrow_forward
- Complete the if-else statement to output "Below 90" if the value of userInput is below 90. Otherwise, output "90 or more". Ex: If the input is 88, then the output is: Below 90 1 import java.util.Scanner; 3 public class Relational { 345678 9 10 11 12 13 14 FREEdd public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userInput; 15 16 } 17 } userInput = scnr.nextInt (); if (* Your code goes here */) { System.out.println("Below 90"); } else { } System.out.println("90 or more");arrow_forwardMad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways. Complete the program to read the needed values from input, that the existing output statement(s) can use to output a short story. Ex: If the input is: Eric Chipotle 12 cars. the output is: Eric went to Chipotle to buy 12 different types of cars. 340136.2251206.qx3zay7 LAB 2.31.1: LAB: Mad Lib 0/10 ACTIVITY LabProgram.java Load default template... 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 6 7 8 9 10 11 11 went to + generic Location + to buy + wholeNumber + different types of Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. AAAAA OF ENP 12 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String firstName; String genericLocation; int…arrow_forward#01.arrow_forward
- JAVA Program ASAP Please modify this program with further modifications which are below so it passes the test cases in Hypergrade. I have provided the failed test cases. 1) For test cases 2 and 3 for the outputted numbers there needs to be commas and there needs to be nothing after that 2)for test case 1 outputted numbers there needs to be nothing after that, 3) for test 4 when file is not found there needs to be nothing after that 4) and for test case 5 and 7 afer a file is not found it needs to display Please re-enter the file name or type QUIT to exit: so you input the text file and displays the numbers. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.InputMismatchException;import java.util.Scanner;public class FileSorting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Please…arrow_forwardjavaarrow_forwardThis code should be working at repl.itarrow_forward
- zain IQ docs.google.com Q The general form of (Compound if) is: If (condition); {statmenet1; } else {statmenet1; } * true False Int mark [5]= { 3, 77, 40, 1233}; * true O False 7. The output of this program is(49): int main ( ){int a=4,sum; while (a<=10) {sum+=a; a+=1;}cout << "The Total = << sum ;} * true Falsearrow_forwardGiven the following program and test cases:mid() { (5,3,2) (4 3 7) (4 7 3)int x,y,z,m;1: read("Enter 3 numbers:",x,y,z); X X X2: m = z; X X X3: if (y<z) X X X4: if (x<y) X5: m = y;6: else if (x<z) X7: m = y; // bug X8: else X X9: if (x>y) X X10: m = y; X11: else if (x>z) X12: m = x; X13: print("Middle number is:", m); X X X} Pass Fail PassWhich is(are) the row(s) with higher suspiciousness using Tarantula formulaQuestion 2 options:44,74,6,77 =========================================================================== Given the following program and test cases:mid() { (5,3,2) (4 3 7) (4 7 3)int x,y,z,m;1: read("Enter 3 numbers:",x,y,z); X X X2: m = z; X X X3: if (y<z) X X X4: if (x<y) X5: m = y;6: else if (x<z) X7: m = y; // bug X8: else X X9: if (x>y) X X10: m = y; X11: else if (x>z) X12: m = x; X13: print("Middle number is:", m); X X X} Pass Fail Passarrow_forwardGiven the snippet of code: int al = {2, 4, 6, 8, 10, 12), x, *p = a; x = *(p + 4)+1; printf("%d", x); What will be the value of x after the following statement is executed? 13 5 12 11arrow_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