C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
Question
Book Icon
Chapter 8, Problem 7PP

(a)

Program Plan Intro

Program Plan: 

  • filename, population, totalCity, cityName, andmayor variables are used in the program.
  • c_str () andclose() functions are used in the program.

Program Description: The main purpose of the program is to create a file to store the collected information about the cities in your state. Prompt the user to enter the data of the each city’s name, their pollution, and the name of the mayor. Store the user-entered data in the file.

(b)

Program Plan Intro

Program Plan: 

  • filename, line, andcityInfovariables are used in the program.
  • getline (), fail (), c_str(), sort (), push_back (), eof (), close (),andexit () functions are used in the program.

Program Description: The main purpose of the program is to read the data from the file created in the exercise 7a. Sort the data in the alphabetically order by the city name.After sorting, display the data.

Blurred answer
Students have asked these similar questions
Instructions(C++) A company hired 10 temporary workers who are paid hourly and you are given a data file that contains the last name of the employees, the number of hours each employee worked in a week, and the hourly pay rate of each employee. You are asked to write a program that computes each employee’s weekly pay and the average salary of all employees. The program then outputs the weekly pay of each employee, the average weekly pay, and the names of all the employees whose pay is greater than or equal to the average pay. If the number of hours worked in a week is more than 40, then the pay rate for the hours over 40 is 1.5 times the regular hourly rate. Use two parallel arrays: a one-dimensional array to store the names of all the employees (Name) a two-dimensional array of 10 rows and 3 columns to store the number of hours an employee worked in a week (Hrs Worked), the hourly pay rate (Pay Rate), and the weekly pay (Salary). Your program must contain at least the following…
(C++ Programming) You are given a file consisting of students’ names in the following form: lastName, firstName middleName. (Note that some students may not have a middle name.) Write a program that converts each name to the following form: firstName middleName lastName. Your program must read each student’s entire name into a variable and must contain a function that takes as input a string, consisting of a student’s name, and returns a string consisting of the altered name. • Use the string function find to find the index of , • the function length to find the length of the string • the function substr to extract the firstName, middleName and lastName. Output the altered name into a file. This program has no user interface. Banks,John William Barret,Ron Drew,Lucy Marie Perry,Mark G Smith,John Carr
(C++ programming) This is all information for the project You are given a file containing many words. Read in all of the words from the file and insert each word into a searchable ADT. Give the user a looping menu allowing them to search for words in the word list. Searches must be be found in O(1) or constant time. Your code must time the search operations, and display the time to the user. For this assignment, you may use the provided word list or another word list with more than 150,000 words. Include this file with your submission. You must design and implement the following classes: Word: This class holds a single word as a string. Basic getters and setters are required. HashTable: This class represents the hash table for storing many words. Main: This is the driver class. The driver: Create a Hash Table Read in all of the words from a text file into the Hash Table Provide a looping menu for the user to perform searches. Time all searches and display the execution time to…
Knowledge Booster
Background pattern image
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