Question

In: Computer Science

Using C++ Many software applications use comma-separated values to store and transfer data. In this program,...

Using C++

Many software applications use comma-separated values to store and transfer data.

In this program, you are asked to implement the movie_call function that will parse a string of the above structure into the corresponding movie name, rating, and movie length.

ex: In "movie name, rating, length", the movie name is "movie name", the rating is "rating", and the length of the movie is "lenght".

This is the code:
#include <iostream>

#include <string>

using namespace std;

/*

Replace the function body with appropriate statements to movie_call

a string of movie details into its corresponding movie name, rating,

and length.

*/

void movie_call (string movie, string& name, string& rating, string& length) {

int comma, comma1;

          comma = movie.find(",");

          name = movie.substr(0, comma);

          movie = movie.substr(comma + 1);

            comma1 = movie.find(",");

            rating = movie.substr(0, comma1);

          length = movie.substr(comma1 + 1);

}

int main() {

string movie_details;

cout << "Please enter information for one movie of your choice: ";

getline(cin, movie_details);

//Add appropriate statement(s) to call the movie_call function

//and display the name, rating, and length

return 0;

}

Solutions

Expert Solution

#include<iostream.h>

#include<string.h>
void movie_call (string movie, string& name, string& rating, string& length) {

int comma, comma1;

         comma = movie.find(",");

         string name = movie.substr(0, comma);

         string movie = movie.substr(comma + 1);
 
         comma1 = movie.find(",");

         int rating = movie.substr(0, comma1);

         int length = movie.substr(comma1 + 1);

}

int main() {

string movie_details;

cout << "Please enter information for one movie of your choice: ";

getline(cin, movie_details);


movie_call (string movie, string& name, string& rating, string& length);
cout<<name<<endl;
cout<<rating<<endl;
cout<<length<<endl;
return 0;

}
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

Download the file data.csv (comma separated text file) and read the data into R using the...
Download the file data.csv (comma separated text file) and read the data into R using the function read.csv(). Your data set consists of 100 measurements in Celsius of body temperatures from women and men. Use the function t.test() to answer the following questions. Do not assume that the variances are equal. Denote the mean body temperature of females and males by μFμF and μMμMrespectively. (a) Find the p-value for the test H0:μF=μMH0:μF=μM versus HA:μF≠μM.HA:μF≠μM. Answer (b) Are the body temperatures...
create a python program that ask for a name and birth year separated by a comma....
create a python program that ask for a name and birth year separated by a comma. the program should keep prompting until the user inputs 'quit'. print the dictionary containing the key value pair name:year in the same order they were inputted. print the name and birth year on a single line for each of the entries. finally print the dictionary with the key value paris swapped and sorted by birth year. from youngest to oldeest.
Write a program using multiple functions. Make use of an array to store data Make use...
Write a program using multiple functions. Make use of an array to store data Make use of searching techniques Read data from a file Write data to a file Instructions: In this lab, you will be examining a set of stock collected over a twenty four day period. Be sure to make use of an array to store these stocks. You will be required to read in the data points from a file. Write a function to read in the...
The producer of a downloadable antivirus software program spends exactly ​$2 comma 650 comma 000 producing...
The producer of a downloadable antivirus software program spends exactly ​$2 comma 650 comma 000 producing the first copy and incurring various costs required to make the software​ "user-friendly." The firm can produce and distribute additional copies at a​ per-unit cost of ​$1.00. If the company sold as many copies as consumers wished to purchase at a price of ​$1.00 per​ copy, it would sell 425 comma 000 copies. If the company maximizes its economic profits in the​ short-run, it...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98').
Write a program which accepts a sequence of comma-separated numbers from console and generate a list...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98'). Input can be comma separated in one line.
In C: You are to create a program to request user input and store the data...
In C: You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment. 1) Define a global...
In C, create a program that displays the minimum and maximum values stored in a data...
In C, create a program that displays the minimum and maximum values stored in a data file "datafile.txt". Use the following function prototype:  void minmaxarray(float value, float *min, float *max);
C++ PLEASE IMPORTANT: The use of vectors is not allowed This program will store roster and...
C++ PLEASE IMPORTANT: The use of vectors is not allowed This program will store roster and rating information for a basketball team. Coaches rate players during tryouts to ensure a balanced team. A roster can include at most 10 players. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int array and the ratings in another int array. Output...
C programming language only! a file is given that has comma-separated integers. the files contents are...
C programming language only! a file is given that has comma-separated integers. the files contents are -1,-9,1,45,3,2,1,-1... Create a function that takes as an input a filename and returns an array containing the list of integers in the file
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT