Concept explainers
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++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Using MIS (10th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
C++ How to Program (10th Edition)
- a) Consider the following code snippet. {:[" if (aNumber ">=0)xi],[" if (anumber "==0" ) "{]:} system.out.println ("first string") ; else {system.out.println ("sécond string"); 3system.out.println("third string") ; i. What output do you think the code will produce if "aNumber" is 3? [2 marks] ii. Write a test program containing the previous code snippet; make "aNumber" 3. What is the output of the program? Explain why the output is what it is i.e what is the control flow for the code snippet? [4 marks] iii. Using only braces, spaces and line breaks, reformat the oode snippet to make the control flow easier to understand. [3 marks] b) Consider the following class: iv. What are the class variables? [1 mark] Solve wh x=7arrow_forwardIf the user types "2" at the "dd?" prompt and "9" at the "xx?" prompt, then what would be the output of the following program?Please note that the operation x % 10 (i.e., x modulo 10) is always the same as the rightmost digit of x (e.g., 123 % 10 = 3). Question options: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 None of these optionsarrow_forwardCount Dracula buys blood from tha public (AIDS tested, of course).But since he prefers certain types to others, he pays as follows:Type A 3000Type B 1800.75Type C (FOR AB) 2880.25Type 0 1500Write a program to input clients name, his/her blood type,and the volume (liters) of blood extracted. Loop exits wheninputted blood type is invalid. Output how much each customer will be paid. java (switch statement)arrow_forward
- In your favorite open world adventure video game, currency conversion is as given below: 1 Gold coin 23 Bolts 1 Gem 13 Gold coins Write a program that takes a number of Bolts as user input (as an integer) and converts it to the number of whole Gems, Gold coins, and Bolts as shown below. The conversion information between these measurement metrics is provided in the table above. The number of Bolts should be converted in such a way that maximizes the whole number of Gems and Gold coins. Expected output 1 (bold is user input) Enter the number of Bolts: 32 0 Gems(s) 1 Gold coin(s) 9 Bolt(s) Expected output 2 (bold is user input) Enter the number of Bolts: 3000 10 Gem(s) 0 Gold coin(s) 10 Bolt(s) The file should be named as convertCurrency.cpp. Don’t forget to head over to Coderunner on Canvas and paste your solution in the answer box!arrow_forwardIn the given code, the values of installment1.dueDate and installment2.dueDateis getting printed same but I want a difference of 5 months in both the dates.Please debug my code so that it gives correct output. var installmentDate = new Date();const installment1 = { "dueDate": Date(installmentDate), "paid":false };console.log(installment1.dueDate);installmentDate.setMonth(installmentDate.getMonth() + 5);const installment2 = { "dueDate": Date(installmentDate), "paid":false };console.log(installment2.dueDate);arrow_forwardIn java write a program that takes four int command-line arguments w, x, y, z,. define a boolean variable whose value is true if the four values are either in strictly acending order (w<x<y<z) or strictly descending order (w>x>y>z), and false otherwise, then display the boolean variable value. Note: Do not use if statements on the program Note: Assume that the inputs will always be integersarrow_forward
- Write a program that prompts the user to input five decimal numbers. The program should then add thefive decimal numbers, convert the sum to the nearest integer, and print the result. Use the static_caststatement with an appropriate equation to convert the sum to an integer. Compile and run yourprogram with the following test data:Case 1: Input: 5.1, 5.1, 5.1, 5.1, 5.1. Expected Output: 26.Case 2: Input: 5.0, 5.0, 5.0, 5.0, 5.0. Expected Output: 25. The language is C++arrow_forwardIn the code given below, the values of installment1.dueDate and installment2.dueDateis getting printed same but I want a difference of 5 months in both the dates.Please debug the code so that it gives correct output. var installmentDate = new Date();const installment1 = { "dueDate": Date(installmentDate), "paid":false };console.log(installment1.dueDate);installmentDate.setMonth(installmentDate.getMonth() + 5);const installment2 = { "dueDate": Date(installmentDate), "paid":false };console.log(installment2.dueDate);arrow_forwardA sales event at Trader Jane's is reducing some items by 25%. Store that value to a properly named constant. Write a program that functions like a cashier terminal for one item. Some items are subject to 7% sales tax and some are not. Use a constant for the sales tax value, too. Write a program for Trader Jane's that runs as shown next: Enter the ticket price of the item 100 Is this item reduced y/n? y is this item taxable y/n? y Here is your bill Original price $100 Reduction during event $25.00 Final price $75.00 7% Sales tax $5.25 Total amount due $80.25arrow_forward
- You are working for a lumber company, and your employer would like a program that calculates the cost of lumber for an order. The company sells pine, fir, cedar, maple, and oak lumber. Lumber is priced by board feet. One board foot equals one square foot that is one inch thick. Theprice per board foot is given in the following table: Pine 0.89Fir 1.09Cedar 2.26 Maple 4.50Oak 3.10 The lumber is sold in different dimensions (specified in inches of width and height, and feet of length) that need to be converted to board feet. For example, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high, and 8 feet long, and is equivalent to 5.333 board feet (2 * 4 * 8 = 64, which when divided by 12 = 5.333 board feet). An entry from the user will be in the form of a letter and four integer numbers. The integers are the number of pieces, width, height, and length. The letter will be one of P, F, C, M, O (corresponding to the five kinds of wood) or T, meaning total. When the letter is T, there are no…arrow_forwardYou are working for a lumber company, and your employer would like a program that calculates the cost of lumber for an order. The company sells pine, fir, cedar, maple, and oak lumber. Lumber is priced by board feet. One board foot equals one square foot that is one inch thick. Theprice per board foot is given in the following table: Pine 0.89Fir 1.09Cedar 2.26Maple 4.50Oak 3.10 The lumber is sold in different dimensions (specified in inches of width and height, and feet of length) that need to be converted to board feet. For example, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high, and 8 feet long, and is equivalent to 5.333 board feet (2 * 4 * 8 = 64, which when divided by 12 = 5.333 board feet). An entry from the user will be in the form of a letter and four integer numbers. The integers are the number of pieces, width, height, and length. The letter will be one of P, F, C, M, O (corresponding to the five kinds of wood) or T, meaning total. When the letter is T, there are no…arrow_forwardPROBLEM: I need to make an ATM program that allows the user to check his or her balance after entering his or her correct PIN and the maintaining balance is Php 8000. A message is shown when the balance is below PHP 8,000 for withdrawal and its remaining balance. Another message is shown when the balance is PHP 8,000 and above for deposit and its updated balance. The code: import random import sys class ATM(): def __init__(self, name, account_number, balance = 0): self.name = name self.account_number = account_number self.balance = balance def account_detail(self): print("\n----------ACCOUNT DETAIL----------") print(f"Account Holder: {self.name.upper()}") print(f"Account Number: {self.account_number}") print(f"Available balance: Nu.{self.balance}\n") def deposit(self, amount): self.amount = amount self.balance = self.balance + self.amount print("Current account…arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT