Menu

[Solved]Need Help Assignment C Please Instructions Programming Style Details Crucial Assignment Q37119726

I need help with this assignment in C++,please!

*** The instructions and programming style detailsare crucial for this assignment

Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a moreTo limit the scope of this assignment we will only consider E.164 phone numbers from the following regions CC Region 1 NorthMain Program Here is an example what it should look like when your main program is run on the file above File Name phoneLog1.Functions to write: You are to write the following seven functions for vour main program to call Function Name What does theFormatting | get Local Phone | Takes one string parameter (phone number) * Returns a formatted local phone number string CounError Handling Your main program should handle incorrectly formatted data field gracefully Consider the following input file// Title: Lab 1 - PhoneCalls.cpp // Purpose: read in a list of phone call records from a file, and output them /I in a more uYou should adopt a consistent style for how you format your curly braces 3. Do it the same way throughout your file. Make sur

Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I’O manipulators, and the string class. File format: Here is an example of a file containing three phone call records: phoneLog1.txt – Notepad File Edit Format View Help 110054 +12062812000 5912 091233 +33140205990 364 145316 +85223677065 180 Each line records one phone call. As you can see, each line contains 3 different fields: start, E.164, and duration Here is an explanation of these three fields: To limit the scope of this assignment we will only consider E.164 phone numbers from the following regions CC Region 1 North America (US, Canada, and some Caribbean islands) 33 France 852 Hong Kong SAR We’ve picked these regions because they have simple 12-digit E.164 formats. Duration: This field consists of a variable number of digits, specifying the number of seconds the cal lasted In this assignment you can assume that a phone log file contains at least one line. In addition, you may assume that each line has exactly three fields and is terminated by an end of line. It is possible that some fields are not formatted correctly. Your program should not crash because a field is incorrectly formatted. Main Program Here is an example what it should look like when your main program is run on the file above File Name phoneLog1.txt Τι me 11:00:54 NA 09:12:33 FR 14:53:16 HK Country Phone Number Durati on (206)-281-2000 98:32 01 40 20 59 90 6:04 2367 7065 3:00 1. The main program first prompts the user to enter a file name, with the following message a. “File Name:” (Case Sensitive) You will open that file for input. 2. a. If the file is not successfully opened, you will print an error message “Failed to open file”, followed by std: :endl, (Case Sensitive) and exit the main program. 3. Print the four column headers, like the following (be careful for spaces and cases Duration Phlonle Nlulmlble r 1 mle Begin the iterative process of reading the three fields on a line 4. The three fields should be read into string variables Then validated before formatting to be outputted in columns as shown above a. b. Your main program should output the same file name prompt, and same column titles as shown in the screenshot. You should also use the exact same field widths. The time field is width 8 (followed by 2 blank spaces), the country field is width 2 (followed by 7 blank spaces), and the phone number field is width 14 (followed by 2 blank spaces). Make sure you zero fill the seconds field of the duration (e.g., 2:03 instead of 2:3) as well Functions to write: You are to write the following seven functions for vour main program to call Function Name What does the function do No Categ 1ValidationisTimeValid * Takes one string parameter (call start time) ** Returns true if the parameter is a valid call start time Should be 6 digits long First 2 digits: Hour, between 00 and 23 Middle 2 digits: Minute, between 00 and 59 Last 2 digits: Second, between 00 and 59 * * * false otherwise Validation | 1sPhoneNumValid|※ Takes one string parameter (phone number) Returns true if the parameter is a valid phone number -Should be 12 characters long *” Starting with +1, +33, or +852 false otherwise 3 Validation isDurationValid * Takes one string parameter (duration) ** Returns true if the parameter is a valid duration string * Should be less than 10 characters long * consisting of number digits between 0 and 9 false otherwise ** * Returns a formatted (HH MM:SS) duration string Takes one string parameter (duration) 4FOormatting formatl ime Example parameter / return values . 110054″”11:00:54″ . “145316” 14:53:16″ 5 Formatting getCountry * Takes one string parameter (phone number) Returns a 3-alpha country code string Country code +1> “NA” Country code +33 → “FR” Country code +852 → “IIK’ Formatting | get Local Phone | Takes one string parameter (phone number) * Returns a formatted local phone number string Country code +1 “”+12062812000” “(206) -281-2000″ Country code +33 “OX XX XXXXXX” . “+33140205990” “01 40 20 59 90” Country code +852 . “+85223677065” “2367 7065” You don’t have to check if it’s valid integer format Converting | stringTo Integer | ※ Takes one string parameter which is a valid integer ** Returns an integer Can be done in a single line: use stoi() function Your main program will call the validation functions FIRST on the data it reads from the file. If a data item is not valid, then your main program will display an error indication for that item (see below) instead of trving to format the data. Error Handling Your main program should handle incorrectly formatted data field gracefully Consider the following input file phonelog2.txt – Notepad File Edit Format View Hel,p 12 +12068372045 abc 081350 12068372045 0000000000 Here’s how it should look when you run with this file File Name :phoneLog2.txt Time ERROR 08:13:50 ERROR Country Phone Number NA Duration (206)-837-2045 -1:-1 ERROR Program Stvle Your program needs to be orderly and readable. If you are working a development team and don’t write clean looking code, you will be unpopular among your colleagues and may not work on that team very long Variables should be given descriptive names that start with a lowercase letter and obey the camelCase convention. Functions should be given descriptive names that start with an uppercase letter and obey the CamelCase convention. First word of a function name typically should be a verb At the start of your file you should have a header comment that gives the title of the assignment, the purpose what class this is for, and your name. Here is an example of what that could look like // Title: Lab 1 – PhoneCalls.cpp // Purpose: read in a list of phone call records from a file, and output them /I in a more user – friendly format to the standard output (cout). // Class: CSC 2430 Spring 2019 // Author: Taiwoo Park Each subordinate function should also start with a header that describes what it does, it’s parameters, what it returns, and how errors are handled. Here is an example: // Produce user friendly version of call start time // Params: string of exactly 6 characters in format hhmmss // Returns: new string formatted HHMASS // Format Error: ERROR if param is not a valid time string You should include additional comments in your code to describe what you are doing. If it is hard to understand what a variable is for, add a comment after it. It possible, though, to put in too many comments, so be judicious and make sure you have time left to do well in your other classes when it comes to commenting You should adopt a consistent style for how you format your curly braces 3. Do it the same way throughout your file. Make sure you indent lines properly If you call open to open a file and it opens successfully, then you should call close to close it when you are done Don’t use global variables Global variables sometimes are appropriate, but not in the assignments we will be giving this quarter Submitting your code Your solution should be contained with in a single C++ file, and it must be named “PhoneCalls.cpp Do not use precompiled headers (such as “stdafx.h” or “pchh”). For more information on this, ask the nstructor In three days from the announcement of this assignment, a zyLabs autograder will be available in the zyBooks Chapter 1. Go submit your file there. zyLabs autograder will run unit tests for your functions as well as input/output tests. You have unlimited opportunities of submission for autograding. You may want to submit an incomplete source code (e.g., not all functions are implemented) to check if your currently implemented functions pass the tests before your full source code submission. Take the full advantage of the autograder Grading Correctness is essential. Make sure your solution builds as described above and correctly handles both “phoneLog1.txt” and “phoneLog2.txt.” We will test on other input file(s) with more number of data records, as well. Even if your code passes all zyLabs autograder tests, points may be taken off for Not following the design described above Not adhering to style guidelines described above Using techniques not presented in class Programming error not caught by other testing Not following good programming practices Show transcribed image text Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I’O manipulators, and the string class. File format: Here is an example of a file containing three phone call records: phoneLog1.txt – Notepad File Edit Format View Help 110054 +12062812000 5912 091233 +33140205990 364 145316 +85223677065 180 Each line records one phone call. As you can see, each line contains 3 different fields: start, E.164, and duration Here is an explanation of these three fields:
To limit the scope of this assignment we will only consider E.164 phone numbers from the following regions CC Region 1 North America (US, Canada, and some Caribbean islands) 33 France 852 Hong Kong SAR We’ve picked these regions because they have simple 12-digit E.164 formats. Duration: This field consists of a variable number of digits, specifying the number of seconds the cal lasted In this assignment you can assume that a phone log file contains at least one line. In addition, you may assume that each line has exactly three fields and is terminated by an end of line. It is possible that some fields are not formatted correctly. Your program should not crash because a field is incorrectly formatted.
Main Program Here is an example what it should look like when your main program is run on the file above File Name phoneLog1.txt Τι me 11:00:54 NA 09:12:33 FR 14:53:16 HK Country Phone Number Durati on (206)-281-2000 98:32 01 40 20 59 90 6:04 2367 7065 3:00 1. The main program first prompts the user to enter a file name, with the following message a. “File Name:” (Case Sensitive) You will open that file for input. 2. a. If the file is not successfully opened, you will print an error message “Failed to open file”, followed by std: :endl, (Case Sensitive) and exit the main program. 3. Print the four column headers, like the following (be careful for spaces and cases Duration Phlonle Nlulmlble r 1 mle Begin the iterative process of reading the three fields on a line 4. The three fields should be read into string variables Then validated before formatting to be outputted in columns as shown above a. b. Your main program should output the same file name prompt, and same column titles as shown in the screenshot. You should also use the exact same field widths. The time field is width 8 (followed by 2 blank spaces), the country field is width 2 (followed by 7 blank spaces), and the phone number field is width 14 (followed by 2 blank spaces). Make sure you zero fill the seconds field of the duration (e.g., 2:03 instead of 2:3) as well
Functions to write: You are to write the following seven functions for vour main program to call Function Name What does the function do No Categ 1ValidationisTimeValid * Takes one string parameter (call start time) ** Returns true if the parameter is a valid call start time Should be 6 digits long First 2 digits: Hour, between 00 and 23 Middle 2 digits: Minute, between 00 and 59 Last 2 digits: Second, between 00 and 59 * * * false otherwise Validation | 1sPhoneNumValid|※ Takes one string parameter (phone number) Returns true if the parameter is a valid phone number -Should be 12 characters long *” Starting with +1, +33, or +852 false otherwise 3 Validation isDurationValid * Takes one string parameter (duration) ** Returns true if the parameter is a valid duration string * Should be less than 10 characters long * consisting of number digits between 0 and 9 false otherwise ** * Returns a formatted (HH MM:SS) duration string Takes one string parameter (duration) 4FOormatting formatl ime Example parameter / return values . 110054″”11:00:54″ . “145316” 14:53:16″ 5 Formatting getCountry * Takes one string parameter (phone number) Returns a 3-alpha country code string Country code +1> “NA” Country code +33 → “FR” Country code +852 → “IIK’
Formatting | get Local Phone | Takes one string parameter (phone number) * Returns a formatted local phone number string Country code +1 “”+12062812000” “(206) -281-2000″ Country code +33 “OX XX XXXXXX” . “+33140205990” “01 40 20 59 90” Country code +852 . “+85223677065” “2367 7065” You don’t have to check if it’s valid integer format Converting | stringTo Integer | ※ Takes one string parameter which is a valid integer ** Returns an integer Can be done in a single line: use stoi() function Your main program will call the validation functions FIRST on the data it reads from the file. If a data item is not valid, then your main program will display an error indication for that item (see below) instead of trving to format the data.
Error Handling Your main program should handle incorrectly formatted data field gracefully Consider the following input file phonelog2.txt – Notepad File Edit Format View Hel,p 12 +12068372045 abc 081350 12068372045 0000000000 Here’s how it should look when you run with this file File Name :phoneLog2.txt Time ERROR 08:13:50 ERROR Country Phone Number NA Duration (206)-837-2045 -1:-1 ERROR Program Stvle Your program needs to be orderly and readable. If you are working a development team and don’t write clean looking code, you will be unpopular among your colleagues and may not work on that team very long Variables should be given descriptive names that start with a lowercase letter and obey the camelCase convention. Functions should be given descriptive names that start with an uppercase letter and obey the CamelCase convention. First word of a function name typically should be a verb At the start of your file you should have a header comment that gives the title of the assignment, the purpose what class this is for, and your name. Here is an example of what that could look like
// Title: Lab 1 – PhoneCalls.cpp // Purpose: read in a list of phone call records from a file, and output them /I in a more user – friendly format to the standard output (cout). // Class: CSC 2430 Spring 2019 // Author: Taiwoo Park Each subordinate function should also start with a header that describes what it does, it’s parameters, what it returns, and how errors are handled. Here is an example: // Produce user friendly version of call start time // Params: string of exactly 6 characters in format hhmmss // Returns: new string formatted HHMASS // Format Error: ERROR if param is not a valid time string You should include additional comments in your code to describe what you are doing. If it is hard to understand what a variable is for, add a comment after it. It possible, though, to put in too many comments, so be judicious and make sure you have time left to do well in your other classes when it comes to commenting
You should adopt a consistent style for how you format your curly braces 3. Do it the same way throughout your file. Make sure you indent lines properly If you call open to open a file and it opens successfully, then you should call close to close it when you are done Don’t use global variables Global variables sometimes are appropriate, but not in the assignments we will be giving this quarter Submitting your code Your solution should be contained with in a single C++ file, and it must be named “PhoneCalls.cpp Do not use precompiled headers (such as “stdafx.h” or “pchh”). For more information on this, ask the nstructor In three days from the announcement of this assignment, a zyLabs autograder will be available in the zyBooks Chapter 1. Go submit your file there. zyLabs autograder will run unit tests for your functions as well as input/output tests. You have unlimited opportunities of submission for autograding. You may want to submit an incomplete source code (e.g., not all functions are implemented) to check if your currently implemented functions pass the tests before your full source code submission. Take the full advantage of the autograder Grading Correctness is essential. Make sure your solution builds as described above and correctly handles both “phoneLog1.txt” and “phoneLog2.txt.” We will test on other input file(s) with more number of data records, as well. Even if your code passes all zyLabs autograder tests, points may be taken off for Not following the design described above Not adhering to style guidelines described above Using techniques not presented in class Programming error not caught by other testing Not following good programming practices

Expert Answer


Answer to I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *