0

Hi every one,

in fact need helps very quicly,

I have project system have to use c++ program but i dont know how to include file in program to read and write.

I will put my soluation to help me some one and the question, to know the person who help me what should program do,
also there error in loop,

hope to help me today,,plz

i want beginning level for solve and my project is video system ,
all things in attachment.

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by noormoon
0

Hi every one,

in fact need helps very quicly,

I have project system have to use c++ program but i dont know how to include file in program to read and write.

I will put my soluation to help me some one and the question, to know the person who help me what should program do,
also there error in loop,

hope to help me today,,plz

i want beginning level for solve and my project is video system ,
all things in attachment.

#include<iostream>
#include<string>
#include <fstream>

using namespace std;


class movie{
private:
	int Id;
	string title;
	int numberofcopies;
	int availablecopies;

public:
	movie ()
	{
		Id=0;
		title="NULL";
		numberofcopies=0;
		availablecopies=0;
	}

	void setId(int i)
	{
		Id=i;
	}

	int getId()
	{
		return Id;

	}


	void settitle(string t)
	{

		title=t;

	}

	string gettitle()
	{
		return title;

	}

	void setnumberofcopies(int c)
	{

		numberofcopies=c;

	}

	int getnumberofcopies()
	{

		return numberofcopies;

	}


	void addnwemoive(string x , int y,int z)
	{

		availablecopies=y;
		numberofcopies=y;
		title=x;
		Id=z;
	}


	void renttap(int i)
	{
		if (Id==i)

			if (numberofcopies>=1)


			{
				cout<<"tap checked out"<<endl;
				
				
				availablecopies=availablecopies-1;

			}

			else 

				cout<<" there is no copy aviable for this title"<<endl;

	}

	void searchbyId (int i)
	{

		if (Id==i)
		{
			cout<<"Id"<<getId()<<endl;
		cout<<"title"<<gettitle()<<endl;
		cout<<"number of copies"<<numberofcopies<<endl;
		}


		else

			cout<<"no moive found"<<endl;

	}


	void searchbytitle(string n)

	{

		if (n==title)

			{
			cout<<"Id"<<getId()<<endl;
		cout<<"title"<<gettitle()<<endl;
		cout<<"number of copies"<<numberofcopies<<endl;
		}


		else

			cout<<"no title found"<<endl;

	}

};

	void main()
	{

		ofstream myfile;
		myfile.open ("d://file.txt");














		movie mymoive[15];

		string name;

		int choice,copy,Id=-1;

		do{

			if (Id<15)
			{


			cout<<" enter number of service:"<<endl;
			cout<<"1-add a new movie."<<endl;
			cout<<"2-rent a tape."<<endl;
				cout<<"3-search a movie by Id."<<endl;
				cout<<"4-search a moive by title."<<endl;
				cout<<"5-exit"<<endl;

			cin>>choice;
			}

			if (choice==1)
			{
				Id=Id+1;
				cout<<"enter the name"<<endl;
				getline(cin,name);
				 
				

				 cout<<"No of copies"<<endl;
				 cin>>copy;

				 mymoive[Id].addnwemoive(name,copy,Id);
					


			}

			else
				if(choice==2)

				{
					cout<<" Enter Id:"<<endl;
					cin>>Id;

					mymoive[Id].renttap(Id);

				}

				else
					if (choice==3)
					{
						cout<<"Enter Id:"<<endl;
						cin>>Id;
						mymoive[Id].searchbyId(Id);
						
					}

					else 
						if(choice==4)

						{
							cout<<"Enter title"<<endl;

							getline(cin,name);

							mymoive[15].searchbytitle(name);

						}

		}while(choice!=5);

		
	}

Edited by Narue: Added code tags

This question has already been answered. 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.