Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CIS 115 Help Please. This code prints an error. Thank you Remarks: Your code contains a run-time error. That means that the code is correct

CIS 115

image text in transcribed

image text in transcribed

image text in transcribed

Help Please. This code prints an error. Thank you

Remarks: Your code contains a run-time error. That means that the code is correct from a language point of view but is doing something 'illegal' at run-time: accessing an invalid memory location, dividing by zero, or something like that. Checking array or other indices, pointers, and loops would be a good idea. Status code: 1 5.18: Population Bar Chart Write a program that produces a bar chart showing the population growth of Prairieville, a small town in the Midwest, at 20 -year intervals during the past 100 years. The program should.read in the population figures for 1 (1900,1920,1940,1960,1980\), and 2000 from a file named People.txt. It is understood that the first value represents the population in 1900 (for example, 2,843), the second the population in 1920 and so on. For each year it should display the year, followed by at least one space followed by a bar consisting of one asterisk for each 1,000 people. (The program should round UP so that a population of 1 would generate one asterisk -- as would 1000 , while a population of 1,001 would generate two, etc.) Prompts And Output Labels. The program is not interactive so there are no prompts. The first line of the output should be PRAIRIEVILLE POPULATION GROWTH and the second line of the output should be (each * represents 1000 people) after which the main output follows. Input Validation. The program should validate each population count read. If the population is ever negative, the program should print the message "BAD DATA" on a line by itself and not process any more data. *include \\#includerfstream> \\#include5\ mathrm { YMBOL }={}\ ); const char CITY [] = "PRAIRIEVILLE"; ifstream infile; infile.open("people.txt"); if (linfile) cout \ ( VII) "Unable to open file." \( \II Ivarangle I) endl; return 1 ; cout CITY " POPULATION GROWTH" \( ((\backslash I \backslash) \) end \(;\) cout "(each" \(\II\) SYMBOL III " reprensents" \(\II\) THOUSAND \( \II" \) people)" \( II \II \) endi; V} Here's the C++ code to solve the problem: Remarks: Your code contains a run-time-error. That means that the code is correct from a language point of view but is doing something "illegal" at run-time: accessing an invathd memory location, dividing by zero, or something like that. Checking array or other indices, pointers, and loops would be a good idea. Status code: 1 Remarks: Your code contains a run-time error. That means that the code is correct from a language point of view but is doing something 'illegal' at run-time: accessing an invalid memory location, dividing by zero, or something like that. Checking array or other indices, pointers, and loops would be a good idea. Status code: 1 5.18: Population Bar Chart Write a program that produces a bar chart showing the population growth of Prairieville, a small town in the Midwest, at 20 -year intervals during the past 100 years. The program should.read in the population figures for 1 (1900,1920,1940,1960,1980\), and 2000 from a file named People.txt. It is understood that the first value represents the population in 1900 (for example, 2,843), the second the population in 1920 and so on. For each year it should display the year, followed by at least one space followed by a bar consisting of one asterisk for each 1,000 people. (The program should round UP so that a population of 1 would generate one asterisk -- as would 1000 , while a population of 1,001 would generate two, etc.) Prompts And Output Labels. The program is not interactive so there are no prompts. The first line of the output should be PRAIRIEVILLE POPULATION GROWTH and the second line of the output should be (each * represents 1000 people) after which the main output follows. Input Validation. The program should validate each population count read. If the population is ever negative, the program should print the message "BAD DATA" on a line by itself and not process any more data. *include \\#includerfstream> \\#include5\ mathrm { YMBOL }={}\ ); const char CITY [] = "PRAIRIEVILLE"; ifstream infile; infile.open("people.txt"); if (linfile) cout \ ( VII) "Unable to open file." \( \II Ivarangle I) endl; return 1 ; cout CITY " POPULATION GROWTH" \( ((\backslash I \backslash) \) end \(;\) cout "(each" \(\II\) SYMBOL III " reprensents" \(\II\) THOUSAND \( \II" \) people)" \( II \II \) endi; V} Here's the C++ code to solve the problem: Remarks: Your code contains a run-time-error. That means that the code is correct from a language point of view but is doing something "illegal" at run-time: accessing an invathd memory location, dividing by zero, or something like that. Checking array or other indices, pointers, and loops would be a good idea. Status code: 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

Students also viewed these Databases questions

Question

12 years professional work experience desirable

Answered: 1 week ago