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 : 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 ie readable to human eyes
Functions that you will need to use:
getlineistream& 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;
getlinecin input;
setwint
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 Output formatting
int stoistring&
This function takes a string, converts it to an integer and returns that integer. For example, the string returns an integer with the value of If it is unable to convert ie the string contains Batman an exception of type invalidargument is thrown, which you will need to catch if you want your program to continue.
trycatch
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 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
Prompt the user for a title for data. Output the title. pt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
