0
#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();
}
4
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by Narue
0

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.

0

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()

0

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

0

>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' );
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.