Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 16.1, Problem 2STE
What would be the output produced by the code in Self-Test Exercise 1 if we make the following change? Change the line
int waitTime = 46; |
to
int waitTime = 12; |
1. What output is produced by the following code?
int waitTime = 46; try { cout << "Try block entered.\n"; if (waitTime > 30) throw waitTime; cout << "Leaving try block.\n"; } catch(int thrownValue) { cout << "Exception thrown with\n" << "waitTime equal to " << thrownValue << endl; } cout << "After catch block." << endl; |
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
d. student
a, int i = (double)
b. int i = (int)
c. int i = ((int) 4.3* 10)/10.0;
d. int i = 3.4 ;
3:
3.4;
2) Which one is a valid casting?
a. x*=0.5
b. x/=2
3) Given a variable x of type double.
Use JAVA to create a card game in which the dealer shuffles the deck and deals 13 cards out of the 52 to the player. The player sorts her hand and says whether it includes the King of Hearts. Repeat this process 4 times so that all the 52 cards are dealt. The player should return true or false without writing to the console. In response, the dealer should write on the console, "You won!" or "You loose again." Also create a unit test for the win and loose cases.
Create an orignal code with Java card graphics. Please do not reshare a similar answer!
java
Chapter 16 Solutions
Problem Solving with C++ (10th Edition)
Ch. 16.1 - Prob. 1STECh. 16.1 - What would be the output produced by the code in...Ch. 16.1 - Prob. 3STECh. 16.1 - What happens when a throw statement is executed?...Ch. 16.1 - In the code given in Self-Test Exercise 1, what is...Ch. 16.1 - Prob. 6STECh. 16.1 - Prob. 7STECh. 16.1 - What is the output produced by the following...Ch. 16.1 - What is the output produced by the program in...Ch. 16.2 - Prob. 10STE
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
- ON 25 Consider the following code snippet : for ( int i = 4; i > 0 ; i -=2) { for ( int j = 2; j >=0; j--) System.out.print( i + "+ j+ ","); System.out.println(); { Complete the following code to produce the same output as the above code. int i = j = 2; while ( i > 0) while ( j>=0 ) { System.out.print( i + " "+ j+ ","); } System.out.println(); i --2; } Write the missing code in the following blank spaces in order :arrow_forwardPart 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.arrow_forwardWrite code that outputs variable numBaths as follows. End with a newline. Ex: If the input is: 3 the output is: Baths: 3 1 import java.util.Scanner; 2 3 public class OutputTest { public static void main (String [] args) { int numBaths; 4 5 // Our tests will run your program with input 3, then run again with input 6. // Your program should work for any input, though. 7 8 new Scanner(System.in); scnr.nextInt(); 9. Scanner scnr = 10 numBaths %3D 11 12 System.out.println(numBaths); 13arrow_forward
- CHALLENGE ACTIVITY Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex: 101 133 3.8.3: Fixed range of random numbers. Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, srand() has already been called; do not call srand() again. See How to Use zyBooks for info on how our automated program grader works. 449096.3145616.qx3zqy7 1 #include 2 #include 3 #include 4 5 int main(void) { 6 int seedVal; 7 8 9 10 11 12 13 14} scanf("%d", &seedVal); srand(seedVal); /* Your solution goes here */ return 0; Run A No solution code provided X Testing with seedVal = 4 // Enables use of rand() // Enables use of time() Your output Your program produced no output Expected output X Testing with seedVal = 55 101 133 Expected output Your output Your program produced no output 148 125 1 test passed All tests passedarrow_forwardQUESTION 4 Analyze the following code: public class Test { public static void main (String [] args) { int i = 0; while (i ++ < 10); System.out.println(i + 4); The program compiles despite the semicolon () on the for loop line, and displays 15. The program has a compile error because of the semicolon (;) on the while loop line. The program compiles despite the semicolon (:) on the while loop line, and displays 4.arrow_forwardava Program ASAP ************This program must work in hypergrade and pass all the test cases.********** Please look closely at the underlined parts of the correct test case. Fix the program below with the following modifications so it outputs the correct test case and nothing else: in Stopandsmelltheroses. the s needs to be Capital, a smaller case, s maller case r smaller case in the sentence and with spaces. The same applies to Atruerebelyouare!Everyone was impressed.You'lldowellto continue in the same spirit. Pleaseexplainabitmoreinthewayoffootnotes.Fromthegiventextit'snotclearwhatarewereadingabout. and Pleaseexplainabitmoreinthewayoffootnotes.Fromthegiventextit'snotclearwhatarewereadingabout. needs to be in another line and with spaces. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.regex.Pattern;import java.util.regex.Matcher;public class WordSeparator { public static void…arrow_forward
- What is the value of x after the following code executes? double m = 2.67;int x = (int)m;arrow_forwardlllustrating your answer using the buggy code below, explain in your own words what it means for variables to be defined “as locally as possible”, and why it is important. This code is intended to print one of two messages depending on whether an integer input is less than a secret number or not. The function, inputInt, correctly prints the given String and then returns a number input by the user.arrow_forwardTask 3 Implement the design of the Passenger class so that the following output is produced: The assumption is Bus base-fare is 450 taka. A passenger can carry upto 20 kg for free. 50 taka will be added if bag weight is between 21 and 50 kg. 100 taka will be added if bag weight is greater than 50 kg. [You are not allowed to change the code below] Output: Total Passenger: 0 # Write your code here print(“Total Passenger:", Passenger.count) == Name: Jack p1 = Passenger(“Jack") Bus Fare: 550 taka p1.set_bag_weight(90) ===== !== p2 = Passenger("Carol") Name: Carol Bus Fare: 450 taka p2.set_bag_weight(10) == p3 = Passenger("Mike") Name: Mike p3.set_bag_weight(25) Bus Fare: 500 taka ==== print("== =") %3D Total Passenger: 3 p1.printDetail() print("== ==") p2.printDetail() print("= =") p3.printDetail() print("== ==") print("Total Passenger:", Passenger.count)arrow_forward
- 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 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_forwardWrite code that outputs variable numBirds as follows. End with a newline. Ex: If the input is: 3 the output is: Birds: 3 1 import java.util.Scanner; 2 3 public class OutputTest { public static void main (String [] args) { int numBirds; 4 // Our tests will run your program with input 3, then run again with input 6. // Your program should work for any input, though. Scanner scnr = new Scanner(System.in); 7 8 10 numBirds scnr.nextInt(); 11 12 /* Your code goes here */ 12arrow_forward3. What does this code print? int i = 0; while (i < 12) { int j; for (j = 0; j < i; j++) { if ((i+j)%3 Ø) == j += 2; } i += j+1; } System.out.println("i = "+i);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
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License