Concept explainers
What would be the output in Self-Test Exercise 15 if the first line were changed to the following?
int firstChoice = 3;
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”;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: Early Objects (6th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Python (4th Edition)
Java How To Program (Early Objects)
Database Concepts (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
- 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 */ 2arrow_forwardjavaarrow_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
- int mystery (int u, int v) { int a; a = u - V; u = a; V = u; return u + v; choose the output of the follos cout << mystery (9,7); Select one: a. 7 b. 4 C. 9arrow_forwardJAVA 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_forwardLanguage:javaarrow_forward
- Given: an int variable num, an int array current that has been declared and initialized, an int variable aNum that contains the number of elements in the array, an int variable bNum that has been initialized, and a bool variable isNum, Write code that assigns TRUE to isNum if the value of bNum can be found in current, and that assigns FALSE to isNum otherwise. Use only num, current, aNum, bNum, and isNum.arrow_forwardjava Which of the following examples is an example of implicit type conversion? int x = 5;int i = 0;double y = 3.75;double z = 0.0;Select one or more options: a.z = x * y; b.z = 5 * y; c.i = x / 5; d.z = (double) x * y; e.i = x * (int) z;arrow_forwardQuestion 2: As a python programmer for an educational institution you are instructed to write a program to simulate the grades for 5 subject areas and display the grade for each based on the following guidelines: Take in the marks of 5 subjects from the user and store it in different variables. 2. Find the average of the marks. 3. Use an else condition to decide the grade based on the average of the marks. 4. Print the Words "Successful Grad Earned" if the student has passed, if the student has failed print the Words" Re-Take Exam" 5. Exit A. Write an algorithm to represent the steps for this program B: Write a program in python to execute the guidelines presented above C. Draw a detailed flowchart to represent the programarrow_forward
- Write in Java pleasearrow_forwardAnalyze the following program fragment: int x; double d = 4; switch (d) { case 0: x = 1; case 2: x = 2; case 4: x = 3; The program has a compile error because the required default case is missing. The switch control variable cannot be double. The programs compiles and runs fine. The program has a compile error because the break statements are missing..arrow_forwardNo plagiarism pleasearrow_forward
- 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