Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3.2, Problem 8STE
What would be the output in Self-Test Exercise 6 if the assignment were changed to the following?
int extra = 0;
6. What output will be produced by the following code, when embedded in a complete
int extra = 2;
if (extra < 0)
cout << “small”;
else if (extra = = 0)
cout << “medium”;
else
cout << “large”;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
7 public static int test1(int x1, int x2){ 8 9 if(x1==0){ 10 x1=10; 11 } 12 if(x2==0){ 13 x2=10 14 } 15 16 return x1*x2; 17 } 18 19 public static int test2(int x2, int x1){ 20 return x2-x1; 21 } 22 public static int input(){ //Don’t need to trace through
//this method to show how it works. Just assume it pulls
//the value for the user. 23 Scanner keyboard = new Scanner(new BufferedReader(new InputStreamReader(System.in))); 24 int counter=0; 25 System.out.print("Please enter an integer: "); 26 while(counter<3 && !keyboard.hasNextInt()) 27 { 28 System.out.println(); 29 String temp=keyboard.next(); 30 System.out.println(temp+" is not an integer. Please reenter an integer."); 31 counter++; 32 33 } 34 return keyboard.nextInt(); 35 } 36 37 38…
This code should be working at repl.it
Mad 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…
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
We can summarize the imperative programming paradigm by saying that it places emphasis on describing a process ...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
In what numbering system are all numeric values written as sequences of 0s and 1s?
Starting Out with Python (3rd Edition)
What is the output produced by the following?
Absolute Java (6th Edition)
Describe two properties that each candidate key must satisfy.
Modern Database Management (12th Edition)
What was the first application for Java?
Concepts of Programming Languages (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
- Write 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_forwardWhat is the value of x after the following code executes? int x=10; if(x++ >10) { x =13; } a. 10 b.9 c.13 d.11arrow_forwardAssignment 2 Q1-Write a program in java to accept a grade and declare the equivalent description: Grade Description E Excellent V Very Good G Good A Average F Fail Test Data : Input the grade :A Expected Output : You have chosen : Averagearrow_forward
- #01.arrow_forwardProblem You have code that needs to perform simple time conversions, like days to seconds, hours to minutes, and so on.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
- Auto-graded programming assignments may use a Unit test to test small parts of a program. Unlike a Compare output test, which evaluates your program's output for specific input values, a Unit test evaluates individual methods to determines if each method: is named correctly and has the correct parameters and return type • calculates and returns the correct value (or prints the correct output) This example lab uses multiple unit tests to test the kilo ToPounds() function. Complete a program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds. 1 kilogram = 2.204 pounds (lbs). Ex: If the input is: 10 the output is: 22.040000000000003 lbs Note: Your program must define the method public static double kiloToPounds (double kilos) The program below has an error in the kilo ToPounds() method. 1. Try submitting the program for grading (click "Submit mode", then "Submit for grading"). Notice that the first two test cases fail, but the…arrow_forwardThe Body Mass Index – BMI is a parameter used to measure the health status of an individual. Various BMI values depicts how healthy or otherwise a person is. Mathematically BMI = WEIGHT/ HIEGHT * HEIGHT Write a java program using either JOptionPane or Scanner to collect the following values of an individual: 1.a. Namea b. Weight c. Height 2. Compute the BMI of that individual 3. Make the following decisions if: a. BMI < 18.5 is under weight b. BMI >=18.5 but <25 considerably healthy c. BMI >=25 but <30 overweight d. BMI >= 30 but <40 Obesity e. BMI >= 40 Morbid Obesity 4. Display the results of the individual 5. Explain your answerarrow_forwardPYTHON PROGRAMMINGarrow_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_forward4 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_forwardComplete only the code. need it asap. no need for comments Type on the text box provided the word VALID if the statement is correct. Otherwise , type INVALID.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY