Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,722 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,297 people online right now. Registration is fast and FREE... Join Now!




Movie Rental Application

3 Pages V  1 2 3 >  
Reply to this topicStart new topic

Movie Rental Application

ChaNgeD
post 5 Dec, 2005 - 07:51 AM
Post #1


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


i started my program but i got to a part of the instuctions im confused about. this is wat i need to do.

i need to make a sale command which ask the user to enter the title of the movie and searches the list of moives. it prints a rejection messafe if the tritle is not found or the movie number and seaeches the list of customers. if the phone number is not found, it prints a rejection message and has the user re-enter a phone number. otherwise it subtracts one from the number of movies available, adds one to the number of movies borowed by the customer, and prints a receipt confirmation message with the customer's name, the movie and category.

i already have the notepad with the customer list and movie list.
u can use strcmp or/and functions.
plz help
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 5 Dec, 2005 - 08:22 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


We'd be more than happy to help you with your program, but we do like to see that the user has made an attempt when it is a school assignment. Please post the code you have written so far. Thanks, and have a great day.
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 5 Dec, 2005 - 08:26 AM
Post #3


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


#include <iostream.h>
struct customer
{
float MainCommand;
};

MainCommand x_[10];
int main()
{
int counter;
ofstream outfile;
for(int i = 10; <= counter; i++)
{
cout << "Welcome to the inventory customers comuter.\n\nThere are 4 main command that can be inputed: \n\n1)§etup 2)§ale 3)Inventory 4)Close\n\n";
cout << "What would you like to do? ";
cin >> x_1[i].MainCommand;
cin.ignore(80, '\n');
while(x_1[i].MainCommand != 1 && x+1[i].MainCommand != 2 && x_1[i].MainCommand != 3 && x_1[i].MainCommand != 4)
{
cout << "Please enter 1, 2, 3, or 4: ";
cin >> x_1[i].MainCommand;
cin.ignore(80, '\n');
}
/*char string1[51];
char string2[51];

cout << "You will be asked to enter two strings. The program will then\n";
cout << "compare the strings to see if they are the same.\n\n";
cout << "Enter string 1: ";
cin.get(string1,50);
cin.ignore(80, '\n');
cout << "Enter string 2: ";
cin.get(string2,50);
cin.ignore(80,'\n');
if (!strcmp(string1, string2))
{
cout << "The strings are the same.\n";
}
else
{
cout << "The strings are different.\n";
}
return 0;
}
*/
(this is wat i have so far and the strcomp or w/e im trying to figure out also, and also i can do the other commands it is just the sale command which i gave u i need help with)

This post has been edited by ChaNgeD: 5 Dec, 2005 - 08:27 AM
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 5 Dec, 2005 - 03:36 PM
Post #4


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


can anyone help me? im lost still crazy.gif
skyhawk or superslot hcan u help me? :? 8(

This post has been edited by ChaNgeD: 5 Dec, 2005 - 05:11 PM
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 5 Dec, 2005 - 05:28 PM
Post #5


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhh dammit im so confused pssh
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 5 Dec, 2005 - 05:59 PM
Post #6


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


#include <fstream> //Header file for file i/o (ofstream/ifstream)

x_1[i].MainCommand //undelcared Variable


Start there.

I would recommend you read some File I/O tutorials before you dive into this.

www.cplus.about.com
www.cprogramming.com
and this website.

EDIT:

Also, may i suggest you use a color coder to make your code more readable.

One can be found in the link in my signature.

Thank you.

This post has been edited by Mrafcho001: 5 Dec, 2005 - 06:00 PM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 5 Dec, 2005 - 06:00 PM
Post #7


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


Well, a few things jump to mind...you have declared a float named MainCommand inside a struct named customer, but you are then trying to declare an array of type MainCommand...that should be an raay of type customer. Secondly, you have declared an array named x_, and are then trying to access an array named x_1. Thirdly, while the retun type of the strcmp() function can be interpreted as a boolean, it is actually an integer.
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 6 Dec, 2005 - 07:37 PM
Post #8


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


woohoo i redid my program and it is good now only one command left to do ty u guys for the help!
post if u want to see my code tongue.gif
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 7 Dec, 2005 - 07:52 AM
Post #9


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


CODE

#include<iostream.h>
#include<fstream.h>
#include<cstdio.h>
#include<cstring.h>
struct customer
{
    name[1000];
    movies[1000];
};
void DisplayMenu();              //Functions
void CommandClose();
int main()
{            
   movie mov;                                          
   customer cust;
    char input[20], line[30];
   ifstream customerfile("customer.dat");                  //Open the files
   ifstream moviefile("movie.dat");
    DisplayMenu();

    if(!customerfile||!moviefile)
    {              //If no file exit the program..
       cout << "Error reading files";
       return 0;        
   }
   else
    {                                                  

       cout << "The file customer.dat contains" << endl;
       while(customerfile.getline(line, 29))               //Gets the line
 {                                              

           if( sscanf(line, "%s %ld %d ", &cust.name, &cust.phone_number, &cust.movies) == 3)  //scans for name phone number and movies
               cout < <cust.name <<" "<< cust.phone_number <<" "<< cust.movies << endl;

           else {              //If there was an error it quits
               cout << "Error in file format" << endl;
               return 0;
           }
       }

       cout << "The file movie.dat contains" << endl;
       while(moviefile.getline(line, 29))        //Gets the line and scans for movie title and the number next to it

 {      
           if(sscanfile(line, "%s %d", &mov.title, &mov.number) == 2)
     {
               cout <<mov.title <<" "<< mov.number <<" "<< endl;
           }
     if ( strcmp( input, mov.title ) == 0 )
     {
   cout << input <<" Found in file with availabililty: " << mov.number;
     }
 }
   }

}
getchar();
CloseCommand();
   return 0;
}

void DisplayMenu()             //Displays the introduction to program
{
cout << "Welcome to the inventory and customers computer.\n\nThere are 4 main commands that can be inputed: \n\n1)Setup 2)Sale 3)Inventory 4)Close\n\n";
cout << "What would you like to do? Please enter the corresponding number\n";
}

void CloseCommand()             //Sends message for user to close program
{
   
    cout << "Thank your for using Movie Rental Program\n";
}
}


This post has been edited by ChaNgeD: 7 Dec, 2005 - 08:17 AM
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 7 Dec, 2005 - 08:18 AM
Post #10


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


i have one error with the #include<cstdio.h>
#include<cstring.h> can u help me plz i have bout 10 minutes.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 7 Dec, 2005 - 08:21 AM
Post #11


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


What is the error? As an FYI, those libraries are <cstring> and <cstdio>.
User is offlineProfile CardPM

Go to the top of the page

ChaNgeD
post 7 Dec, 2005 - 08:24 AM
Post #12


New D.I.C Head

*
Joined: 5 Dec, 2005
Posts: 28


My Contributions


Cannot open include file: 'cstdio.h': No such file or directory
User is offlineProfile CardPM

Go to the top of the page

3 Pages V  1 2 3 >
Reply to this topicStart new topic
Time is now: 11/20/08 10:08AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month