Homework Help Question & Answers

//Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; cl...

//Need help ASAP in c++ please. Appreciate it! Thank you!!

//This is the current code I have.

#include <iostream>

#include <sstream>

#include <iomanip>

using namespace std;

class googlePlayApp {

private:

string name;

double rating;

int numInstalls;

int numReviews;

double price;

  

public:

googlePlayApp(string, double, int, int, double);

~ googlePlayApp();

googlePlayApp();

  

string getName();

double getRating();

int getNumInstalls();

int getNumReviews();

string getPrice();

  

void setName(string);

void setRating(double);

void setNumInstalls(int);

void setNumReviews(int);

void setPrice(double);

};

googlePlayApp::googlePlayApp(string n, double r, int ni, int nr, double pr) {

name = n;

rating = r;

numInstalls = ni;

numReviews = nr;

price = pr;

//cout << "In the constructor with arguments" << endl;

}

googlePlayApp::googlePlayApp() {

name = "No Name App";

rating = 0;

numInstalls = 0;

numReviews = 0;

price = 0;

//cout << "In the default constructor" << endl;

}

googlePlayApp::~googlePlayApp() {

}

string googlePlayApp::getName() {

return name;

}

double googlePlayApp::getRating() {

return rating;

}

int googlePlayApp::getNumInstalls() {

return numInstalls;

}

int googlePlayApp::getNumReviews(){

return numReviews;

}

string googlePlayApp::getPrice() {

if(price == 0.0)

return "Free";

  

else {

double p = price;

stringstream st;

st << fixed << setprecision(2) << p;

string s = st.str();

return ("$" + s);

}

}

void googlePlayApp::setName(string n) {

name = n;

}

void googlePlayApp::setRating(double r) {

rating = r;

}

void googlePlayApp::setNumInstalls(int ni) {

numInstalls = ni;

}

void googlePlayApp::setNumReviews(int re) {

numReviews = re;

}

void googlePlayApp::setPrice(double p) {

price = p;

}

int main() {

googlePlayApp App1("Whatsapp", 4.5,100000000, 49897441,0.0);

cout << "Name: " << App1.getName() << endl;

if(App1.getNumInstalls() > 1000000) {

cout << "Number of installs:1M+ " << endl;

}

else

cout << "Number of installs: " << App1.getNumInstalls() << endl;

cout << "Rating : " << App1.getRating() << endl;

cout << "Price : " << App1.getPrice() << endl;

cout << "Number of reviews: " << App1.getNumReviews() << endl;

googlePlayApp App2("PicsArt", 4.7, 1009800000, 4997441, 4.99);

cout << "Name: " << App2.getName() << endl;

if(App2.getNumInstalls() > 1000000) {

cout<<"Number of installs:1M+ "<<endl;

}

else

cout << "Number of installs: " << App2.getNumInstalls() << endl;

cout << "Rating : " << App2.getRating() << endl;

cout << "Price : " << App2.getPrice() << endl;

cout << "Number of reviews: " << App2.getNumReviews() << endl;

googlePlayApp App3("Oxford Dictionary", 4.8, 100000, 50000, 6.99);

cout << "Name: " << App3.getName() << endl;

if(App3.getNumInstalls() > 1000000) {

cout << "Number of installs:1M+ " << endl;

}

else

cout << "Number of installs: " << App3.getNumInstalls() << endl;

cout << "Rating : " << App3.getRating() << endl;

cout << "Price : " << App3.getPrice() << endl;

cout << "Number of reviews: " << App3.getNumReviews() << endl;

}

/And these following needs to be incorporated into it. Any help would be appreciated. In C++.Thank you

Your class implementation from Lab #10 should have at least these fields, with setters and getters for all:

name
rating
numInstalls
numReviews
price
Assignment:

The supplied file - apps.csvPreview the document - has a list of 25 actual Google Play apps in a common file format called CSV (Comma-Separated Values). This is a text file that has a series of lines representing rows and columns. Each line is a row with a series of column values, separated by a comma (,). The order of the fields in the file is as follows:

name, category, rating, numInstalls, numReviews, price

All of these fields should be in your googlePlayApp class already, except for category, which should be a string. Add that field to the class and the constructor with arguments, including setters/getters.

We will review an example way of processing a CSV file in class.

Read the supplied CSV file as input with one app. per line, and store each entry in a dynamic structure (a dynamic array -- not a fixed-size array -- or a vector). Each class should be allocated based on a single line in the file.

After the file has been read, go into an "app directory" loop and prompt the user for an application name. If there is a match for that name in the list, print out that the information for that app.

Requirements:

1) The CSV file must be read as input and any app. should be queryable. No hard-coded arrays of strings, etc. will be accepted.

2) Allocate each googlePlayApp dynamically based on each entry in the file.

3) Use any search algorithm to find the name. Linear search (walking through the array, checking for a match, until the end or a match is found) is OK.

4) Print all of the info about the app (the above fields, including category, and the special formatting of 'price') using the 'getter' methods.

5) If the user enters a name that is not found, output 'Name not found' or similar. Continue in the loop until some sentinel value is read (such as a blank line, or an 'X', etc.), then exit.

//apps.csv:

Photo Editor Selfie Camera Filter & Mirror

Image,PHOTOGRAPHY,4.3,922444,527247,0.0

Little Fire Station,FAMILY,4.2,8293,3762,0.0

Mercari: The Selling App,SHOPPING,4.4,203841,101883,1.99

My Android Device S/W & H/W,FAMILY,4.5,889,681,1.99

Sleep as Android Gear Addon,HEALTH_AND_FITNESS,2.8,4299,961,4.99

Girls hairstyles 2018,BEAUTY,4.2,423,62,0.0

Calendar Widget Month + Agenda,PRODUCTIVITY,4.2,72042,60840,4.99

EZ App Installer,TOOLS,4.1,4924,533,4.99

Bleacher Report Live,SPORTS,4.0,3322,232,2.99

Access Point Names,COMMUNICATION,4.0,993,138,0.99

Helix Jump,GAME,4.2,2498552,1498648,0.99

Mail1Click - Secure Mail,COMMUNICATION,4.1,432,255,4.99

Fidget Spinner,GAME,4.2,429394,307398,0.0

Listen and learn English in seven days,EDUCATION,4.3,9342,1516,1.99

Insightly CRM,BUSINESS,3.8,2035,1383,0.99

Questland: Turn Based RPG,FAMILY,4.6,55225,31134,0.99

AV High School District,FAMILY,3.5,224,91,9.99

TFO BZ Lessons,FAMILY,4.4,596,75,0.99

X Launcher: With OS11 Style Theme & Control

Center,ART_AND_DESIGN,4.7,75662,5754,0.99

HD Video Player,VIDEO_PLAYERS,4.3,7234,1551,0.99

Hangouts,COMMUNICATION,4.0,4419350,3419249,0.00

HTC Sense Input-CA,TOOLS,3.1,441,124,0.00

Moto Z Market,TOOLS,2.2,702,605,0.99

Greater London A-Z 2016,TRAVEL_AND_LOCAL,3.7,800,40,0.00

AP Government Review,FAMILY,4.7,44,3,0.00

Example output:

Read 25 apps.
Please enter an application name (X to quit): Little Fire Station

Name: Little Fire Station
Category: FAMILY
Rating: 4.2
Number of installs: 8293
Number of reviews: 3762
Price: Free

Please enter an application name (X to quit): Moto Z Market

Name: Moto Z Market
Category: TOOLS
Rating: 2.2
Number of installs: 702
Number of reviews: 605
Price: 0.99

Please enter an application name (X to quit): Nonexistent app
Application not found.
Please enter an application name (X to quit): X
0 0
Next > < Previous
ReportAnswer #1

// C++ program to create a class googlePlayApp

#include <iostream>

#include <sstream>

#include <iomanip>

#include <fstream>

using namespace std;

class googlePlayApp {

private:

               string name;

               string category;

               double rating;

               int numInstalls;

               int numReviews;

               double price;

public:

               googlePlayApp(string,string, double, int, int, double);

               ~ googlePlayApp();

               googlePlayApp();

               string getName();

               string getCategory();

               double getRating();

               int getNumInstalls();

               int getNumReviews();

               string getPrice();

               void setName(string);

               void setRating(double);

               void setNumInstalls(int);

               void setNumReviews(int);

               void setPrice(double);

               void setCategory(string);

};

googlePlayApp::googlePlayApp(string n,string c, double r, int ni, int nr, double pr) {

               name = n;

               category = c;

               rating = r;

               numInstalls = ni;

               numReviews = nr;

               price = pr;

}

googlePlayApp::googlePlayApp() {

               name = "No Name App";

               category = "No category";

               rating = 0;

               numInstalls = 0;

               numReviews = 0;

               price = 0;

}

googlePlayApp::~googlePlayApp() {

}

string googlePlayApp::getName() {

               return name;

}

string googlePlayApp::getCategory()

{

               return category;

}

double googlePlayApp::getRating() {

               return rating;

}

int googlePlayApp::getNumInstalls() {

               return numInstalls;

}

int googlePlayApp::getNumReviews(){

               return numReviews;

}

string googlePlayApp::getPrice() {

               if(price == 0.0)

                              return "Free";

               else {

                              double p = price;

                              stringstream st;

                              st << fixed << setprecision(2) << p;

                              string s = st.str();

                              return ("$" + s);

               }

}

void googlePlayApp::setName(string n) {

               name = n;

}

void googlePlayApp::setRating(double r) {

               rating = r;

}

void googlePlayApp::setNumInstalls(int ni) {

               numInstalls = ni;

}

void googlePlayApp::setNumReviews(int re) {

               numReviews = re;

}

void googlePlayApp::setPrice(double p) {

               price = p;

}

void googlePlayApp::setCategory(string c)

{

               category = c;

}

int main() {

               ifstream fin("apps.csv"); // provide full path to file

               googlePlayApp **apps; // create a dynamic array of googlePlayApp objects

               int n;

               string line;

               string name;

               string category;

               double rating;

               int numInstalls;

               int numReviews;

               double price;

               bool found;

               // if file can be openend

               if(fin.is_open())

               {

                              n=0;

                              // read till end of file, counting the number of records in file

                              while(!fin.eof())

                              {

                                             getline(fin,line);

                                             n++;

                              }

                              fin.close(); //close the file

                              apps = new googlePlayApp*[n]; // allocate array for googlePlayApp pointer objects

                              fin.open("apps.csv"); //re-open the file

                              int i=0;

                              int index;

                              // read the records in the array reading the file till the end

                              while(!fin.eof())

                              {

                                             getline(fin,line);

                                             line = line.substr(0,line.length()-1);

                                             index = 0;

                                             name = line.substr(index,line.find(','));

                                             index = line.find(',',index+1);

                                             category = line.substr(index+1,line.find(',',index+1)-(index+1));

                                             index = line.find(',',index+1);

                                             stringstream ratingStr(line.substr(index+1,line.find(',',index+1)-(index+1)));

                                             ratingStr>>rating;

                                             index = line.find(',',index+1);

                                             stringstream installsStr(line.substr(index+1,line.find(',',index+1)-(index+1)));

                                             installsStr>>numInstalls;

                                             index = line.find(',',index+1);

                                             stringstream reviewsStr(line.substr(index+1,line.find(',',index+1)-(index+1)));

                                             reviewsStr>>numReviews;

                                             index = line.find(',',index+1);

                                             stringstream priceStr(line.substr(index+1));

                                             priceStr>>price;

                                             apps[i] = new googlePlayApp(name,category,rating,numInstalls ,numReviews ,price);

                                             i++;

                              }

                              fin.close();

                              // output the number of apps read

                              cout<<"Read "<<n<<" apps"<<endl;

                              // loop that continue till the user wants

                              do

                              {

                                             found = false;

                                             // input the application name

                                             cout<<"\nPlease enter an application name (X to quit): ";

                                             getline(cin,line);

                                             line = line.substr(0,line.length()-1);

                                             // check if user wants to quit

                                             if((line.compare("x") == 0) || (line.compare("X") == 0))

                                                            break;

                                             // loop to find the application in the array, if found print the details

                                             for(i=0;i<n;i++)

                                             {

                                                            if(line.compare(apps[i]->getName()) == 0)

                                                            {

                                                                           found = true;

                                                                           cout<<"Name : "<<apps[i]->getName()<<endl;

                                                                           cout<<"Category : "<<apps[i]->getCategory()<<endl;

                                                                           cout<<"Rating: "<<apps[i]->getRating()<<endl;

                                                                           cout<<"Number of installs: "<<apps[i]->getNumInstalls()<<endl;

                                                                           cout<<"Number of reviews: "<<apps[i]->getNumReviews()<<endl;

                                                                           cout<<"Price: "<<apps[i]->getPrice()<<endl;

                                                            }

                                             }

                                             if(!found)

                                                            cout<<"Application not found."<<endl;

                              }while((line.compare("X") != 0) && (line.compare("x") != 0));

                              // release the memory allocated for the objects

                              for(int i=0;i<n;i++)

                                             delete(apps[i]);

                              delete []apps;

               }

               return 0;

}

//end of program

Output:

Input file:

Output:

Read 25 apps Please enter an application name (X to quit): Little Fire Station NameLittle Fire Station Category FAMILY Rating

Know the answer?
Add Answer of:
//Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; cl...
Your Answer: Your Name: What's your source?
Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //==...

    PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() { amount = 0.0; } }; //============================================================================ // Linked-List class definition //============================================================================ /** * Define a class containing data members and methods to *...

  • //Vehicle.h #pragma once #include<iostream> #include"Warranty.h" #include<string> using namespace std; class Vehicle{ protected:    string make; int year;   ...

    //Vehicle.h #pragma once #include<iostream> #include"Warranty.h" #include<string> using namespace std; class Vehicle{ protected:    string make; int year;    double mpg;    Warranty warranty;    static int numOfVehicles; public:    Vehicle();    Vehicle(string s, int y, double m, Warranty warranty);    Vehicle(Vehicle& v);    ~Vehicle();    string getMake();    int getYear();    double getGasMileage();    void setMake(string s);    void setYear(int y);    void setYear(string y);    void setGasMileage(double m);    void setGasMileage(string m);    void displayVehicle();    static int getNumVehicles();    Warranty getWarranty();    void setWarranty(Warranty& ); }; //Vehicle.cpp #include "Vehicle.h" #include <string> Vehicle::Vehicle() {    make = "unknown";    year =...

  • Need help with code C++

    Using the classes designed in PE 6 and 7, write a program to simulate a bookstore. The bookstore has two types of customers: those who are members of the bookstore andthose who buy books from the bookstore only ocasionally. Each member has to pay a 10$ yearly membership fee and recieves a 5% discount on each book purchased.For each member, the bookstore keeps track of the number of books purchased and the total amount spent. For every eleventh book that...

  • finish c++ code Lifesaver awarded + need ASAP

    Can you complete the highlighted areas thanks.Here are the instructions:Can you please write the code ASAP. Mine still doesn't work. I need all requirements mets. Life saver rating awarded. Thanks.Write a Video Rental and Sale Store Management Program. Each video record will manage a name, a code number (unique), a quantity owned by the store, a quantitythat are currently rented out and a quantity that have been sold. The program will accept the following commands listed below:a) HELP will list...

  • In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits&gt...

    In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits> #include <iostream> #include <string> // atoi #include <time.h> #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ const unsigned int DEFAULT_SIZE = 179; // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() {...

  • Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #inc...

    Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...

  • How do I write this in C++

    Using the PhoneData class below, overload the ostream operator (<<). You need to make this a friend function of the PhoneData class.For example, in your PhoneData header file under the public section put this:friend ostream&operator<<(ostream&, const PhoneData&);Then define it in the implementation file.To test your class create a main file that does the following:Creates 2 PhoneData objects and assigns values to data members.For example, when creating your objects do the following:PhoneData pd1("Susan Meyers", "414 444-4444");PhoneData pd2("Joy Rodgers", "888 888-8888");Then use...

  • I NEED A PSEUDOCODE ALGORITHM FOR THIS CODE PLEASE C++: #include #include #include #include using...

    I NEED A PSEUDOCODE ALGORITHM FOR THIS CODE PLEASE C++: #include #include #include #include using namespace std; int NumOfEmployees(); int TotDaysAbsent(int); double AverageAbsent(int, int); int main() {         cout << endl << "Calculate the average number of days a company's employees are absent." << endl << endl;      int numOfEmployees = NumOfEmployees();         TotDaysAbsent(numOfEmployees);    return 0; } int NumOfEmployees() {    int numOfEmployees = 0;     cout << "Please enter the number of employees in the company: ";         cin >> numOfEmployees;     while(numOfEmployees <= 0)     {            ...

  • The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib>...

    The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #define MAX 1000 using namespace std; //Function to Add a new inventory item to the data into the array in memory void addItem(string desc[],string idNum[], float prices[], int qty[],int &num) { cout<<"Enter the names:"; cin>>desc[num]; cout<<"Enter the item number:"; cin>>idNum[num]; cout<<"Enter the price of item:"; cin>>prices[num]; cout<<"Enter the...

  • In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double...

    In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...

Free Homework App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
Share Your Knowledge

Post an Article
Post an Answer
Post a Question with Answer

Self-promotion: Authors have the chance of a link back to their own personal blogs or social media profile pages.