Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The programming language is C++ PA7- Water Bill Part A (getting information) Iteration, Selection, And/Or Logical Operators, Data Validation, Value and Reference Parameters, File Processing

image text in transcribed

image text in transcribed

image text in transcribed

The programming language is C++

PA7- Water Bill Part A (getting information) Iteration, Selection, And/Or Logical Operators, Data Validation, Value and Reference Parameters, File Processing Write a program that will get the billing information for a local water company and store it in a file The water company has different types of customers and their rates vary depending on how the water is used The company uses letter codes to identify the following types of customers H for home, C for commercial, and I for industrial The information collected for each account includes: the customer name, the account number, the code for the account type (H, C or I) and the amount of water used Input Data: Get the following data from the user by calling your library function:s Customer Name: multiword string class object of max size 20 characters create a generic readName Account Number integer in the range 1000 to 9999 - use readlnt Account Type character H. C. or I-create an overloaded readChar Usage Amount: floating point with a minimum value of 0- use readDouble Specifications for Program Overload your readChar library function to create another generic, reusable function that will read and validate one of three possible characters by adding an extra char parameter. When tested move this function (and its prototype) to your library of reusable functions 1. 2. Modify your readDouble function to add formatting for the min and max parameters such that very large anc very small numbers (perhaps above 1e6 and below 1e-6) are displayed in scientific notation and other numbers and 0 are displayed in fixed decimal format. Use a precision of 6 for both formats. Code by using the ternary conditional operator?: and the logical operators && (and) I (or) in the error message cout statement 3. Create a new value-returning function of type string called readName that will be a generic, reusable function that can be used to read, validate and return a name. The function should only accept alphabetic letters and special characters such as apostrophe, period, comma, hyphen, a blank space, etc. that are typically valid for a name. See more on last page. When tested move this function (and its prototype) to your library Note: you may want to code some driver functions to test the above library functions 4. The main function shall be iterative, processing one record at a time until all data has been entered and valid records are written to a file as described below. Use your readChar function to receive user answers to continue entering records or to quit a. Include the header file b. In main, just below your variable definition area, define an ofstream (output file stream) object, open and attach it to an output text file and check for successful file opening. Note: if the output text file does not exist as in this case, it will by default, be automatically created in the project directory and the file will be overwritten with each execution of the program ofstream fout; fout.open ("Water Bill Records.txt"); // attach the file stream to the physical file if ( fout.fail)) // fout is a user-defined object of type ofstream // if the file is not opened successfully cout header file b. In main, just below your variable definition area, define an ofstream (output file stream) object, open and attach it to an output text file and check for successful file opening. Note: if the output text file does not exist as in this case, it will by default, be automatically created in the project directory and the file will be overwritten with each execution of the program ofstream fout; fout.open ("Water Bill Records.txt"); // attach the file stream to the physical file if ( fout.fail)) // fout is a user-defined object of type ofstream // if the file is not opened successfully cout

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

demonstrate the importance of induction training.

Answered: 1 week ago