#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <iomanip.h>

class hope
{
char st_title[25];
char st_website[35];
char st_star[25];
char st_maker[25];
char st_rating[5];
int i_minutes;
int i_year;
float f_cost;
int i_age;
char st_status[6];
char st_response[20];
char ch_option;
void getdata();
void processdata();
void putdata();

public:
void run();
}dvd;

void main()
{
char ch_option;
do{
        void run();
}while(ch_option != 'n');
}

void hope::run()
{

dvd.getdata();
dvd.processdata();
dvd.putdata();

}

void hope::getdata()
{
        cout << "\n\nPlease enter title of DVD: ";
        cin.getline(st_title,25);

        cout << "\n\nPlease enter cost of DVD: ";
        cin >> f_cost;

        cin.get();

        cout << "\n\nPlease enter web site: ";
        cin.getline(st_website,35);

        cout << "\n\nPlease enter rating: ";
        cin.getline(st_rating,5);

        cout << "\n\nPlease enter number of minutes: ";
        cin >> i_minutes;

        cin.get();

        cout << "\n\nPlease enter star of movie: ";
        cin.getline(st_star,25);

        cout << "\n\nPlease enter year of copyright: ";
        cin >> i_year;

        cin.get();

        cout << "\n\nPlease enter maker of movie: ";
        cin.getline(st_maker,25);

        cout << "\n\nPlease enter customer age: ";
        cin >> i_age;

}

void hope::processdata()
{
if(i_age < 18 || st_rating == "G")
 {
        strcpy(st_status,"Child");
        strcpy(st_response,"Purchase Authorized");
  }

if(i_age >= 18 || st_rating != "G")
  {
        strcpy(st_status,"Adult");
        strcpy(st_response,"Purchase Authorized");
  }
if(i_age < 18 && st_rating != "G")
  {
        strcpy(st_status,"Child");
        strcpy(st_response,"Cannot Purchase");
  }
if(i_age >= 18)
  {
        strcpy(st_status,"Adult");
        strcpy(st_response,"Purchase Authorized");
  }
}

void hope::putdata()
{
        cout << "\n\nDVD Purchase";
        cout << "\n\n\nTitle: " << st_title;
        cout << "\nWeb Site: " << st_website;
        cout << "\nStar: " << st_star;
        cout << "\nMaker of Film: " << st_maker;
        cout << "\nRating: " << st_rating;
        cout << "\nNumber of Minutes: " << i_minutes;
        cout << "\nYear of Copyright: " << i_year;
        cout << setiosflags(ios::fixed)
             << setiosflags(ios::showpoint)
             << setprecision(2);
        cout << "\nCost:$ " << f_cost;
        cout << "\nCustomer Age: " << i_age;
        cout << "\nStatus: " << st_status;
        cout << "\nResponse: " << st_response;
        cout << "\n\n\nDo you want to continue(y\\n)? ";
        cin >> ch_option;
        cin.get();
}

Recommended Answers

All 4 Replies

What's "wrong" with it? Is it producing results you didn't expect? Is the compiler throwing out errors or something?

Let us know what you expect to happen, and what you're actually getting. That way, we can more accurately help you out.

when I compiled it it didnt do anything I didnt get any errors or anything like that it just dont do anything. It is suppose to run the getdata(), processdata(), and the putdata()

I'm no pro... but would it have anything to do with lacking the "using namespace std;"
after your includes? ...just a shot

>void run();
This is a function declaration, not a call. You need to call dvd's run member function:

int main() // void main is ALWAYS wrong!
{
  char option;

  do {
    dvd.run();

    // Get option
    // ...
  } while ( option != 'n' );
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.