Question: Lab 1 : Data visualization In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output

Lab 1: Data visualization
In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output operations to take some data and format it in a way thats presentable (i.e. readable to human eyes).
Functions that you will need to use:
getline(istream&, string&)
This function allows you to get input for strings, including spaces. It reads characters up to a newline character (for user input, this would be when the enter key is pressed). The first parameter is typically cin, with the second parameter a string you want to read, like this:
string input;
getline(cin, input);
setw(int)
This looks like a function, but is really a stream manipulator. It allows you to specify how many characters the next output should be. This is useful when trying to line things up different outputs. (For more information look at section 12.1 Output formatting)
int stoi(string&)
This function takes a string, converts it to an integer and returns that integer. For example, the string "-24" returns an integer with the value of -24. If it is unable to convert (i.e. the string contains Batman), an exception of type invalid_argument is thrown, which you will need to catch if you want your program to continue.
try/catch
Not functions, but keywords, these are used to handle exceptions. Sometimes operations can fail to generate the correct results, while other times they may fail to generate ANY result. This could be due to incorrect input, going out of bounds of an array, and a variety of other cases. For more information, look at section 15.1 Exception basics.
Input Processing
Handling input will require the following steps:
Get input from the user in the form of a string (see the getline() function, above)
Check to see if that string has ONE comma in it
Split the string based on that comma into two parts
Convert the second part into an integer
Input Validation
For strings, validation is typically handled by checking to see if a string is equal to something, or perhaps whether it contains a certain character, or number of characters, etc.
For numeric values, though, while we typically validate whether its in a certain range or not, there is the possibility of something not being a number to begin with (for example, the user enters dinosaur when prompted to enter a number).
Assignment Details
(1) Prompt the user for a title for data. Output the title. (1 pt)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!