Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 18.3, Problem 19STE

Explanation of Solution

Modified code:

The modified code for given display 18.17 is shown below:

//Header file

#include <iostream>

#include <list>

#include <algorithm>

//std namespace

using std::cin;

using std::cout;

using std::endl;

using std::list;

using std::find;

//Min function

int main( )

{

        /* Declare line in "list" template */

        list<char> line;

        /* Display prompt statement */

    cout << "Enter a line of text:\n";

        //Declare variable for "next"

        char next;

    /* Read text from user */

        cin.get(next);

        /* If "next" is not equal to "\n" */

        while (next != '\n')

        {

            /* Insert the character to list */

            line.push_back(next);

            /* Read the next character */

            cin.get(next);

        }

  /* Declare char varaible "where" in constant iterator */

        list<char>::const_iterator where;

  /* where is located at the first occurrence of 'e' in line.*/

        where = find(line.begin( ), line.end( ), 'e');

  /* Declare char variable "p" in constant iterator */

    list<char>::const_iterator p;

        /* Display statement */

  cout << "You entered the following before you entered your first e:\n";

  /* Using "for" loop, display located at the first occurrence of 'e' in line */

        for (p = line...

Blurred answer
Students have asked these similar questions
C++ A robot is initially located at position (0; 0) in a grid [?5; 5]  [?5; 5]. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move and the current position of the robot. If the robot makes a circle, which means it moves back to the original place, print "Back to the origin!" to the console and stop the program. If it reaches the boundary of the grid, print \Hit the boundary!" to the console and stop the program. A successful run of your code may look like:Down (0,-1)Down (0,-2)Up (0,-1)Left (-1,-1)Left (-2,-1)Up (-2,0)Left (-3,0)Left (-4,0)Left (-5,0)Hit the boundary! or Left (-1,0)Down (-1,-1)Right (0,-1)Up (0,0)Back to the origin! About: This program is to give you practice using the control ow, the random number generator, and output formatting. You may use <iomanip> to format your output.ˆ ˆ You may NOT use #include "stdafx.h".
1. Write a Java program that would resemble banking transactions of deposits, withdrawals, bank to bank transfers, and interest computations. A transaction input window is to be used in entering the account number, transaction code, and amount. Search a 2d-ArrayList containing the account number and the current balance, and then do the appropriate update on the 2d-ArrayList depending on the transaction code. If the transaction code is “D”, update the current balance by adding the amount; if “W”, update the current balance by subtracting the amount from the current balance provided that a withdrawal transaction is allowed (current balance must be greater than the amount to be withdrawn, and the resulting balance must not be less than 500). Display the updated 2d-ArrayList before exiting the program. (USE OOP CONCEPT JFRAME)
The function remove of the class arrayList removes only the first occurrence of an element. Add the function removeAll to the class arrayList that would remove all occurrences of a given element. Also, write the definition of the function removeAll and a program to test this function
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education