Jump to content

Ergent please I need someone to correct my work!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Q-Girl

Q-Girl

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Hello Everyone

Ihave this project and it does not compile with me Ineed an expert to correct it to me please Ihave only one day to re submitit please can any one help me??

i put the description in the attachment ^^

Attached Files


Edited by Q-Girl, 16 January 2010 - 06:27 AM.


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What error messages are you getting? I don't have Visual C++, so may not be able to compile it, but can probably point out issues based on compiler messages.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Q-Girl

Q-Girl

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
unable to find the sytem could not the file spicefid!!

#4
Q-Girl

Q-Girl

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Iwill post my work here
	#ifndef PRODUCT_H

	#define PRODUCT_H

	#include <iostream>

	using namespace std;

	#include <string>


	class Product{

		private:

	int productId;

	string productName;

	double productPrice;

	public:

		Product();

		Product(int,string,double);

		Product(string);

		int setProuductId(int);

		int getprouductId();

		string setProuductName(string);

		string getProuductName();


		double setProuductPrice(double);

		double getProductPrice();

                string callToString(int ,string ,double);

};


	


	#endif

		#include <iostream>

		using namespace std;

		#include<string>

		#include"product.h"


		Product::Product(){

			 productId=0;

		productName="";

		 productPrice=0;


		Product:: Product(int id ,string name,double price){


			 getProuductId;

			getrouductName;

			setProuductPrice;

		}

		string Product::Product(string stringstatment){

			istringstream iss(stringstatment);

			iss>>productId>>productName>>productPrice;


			

		}


		string Product::callToString(int id,string name,double price){


		ostringstream outstr;

		outstr<<id<<" "<<name<<" "<<price;



		return outstr.str();

		}





		int Product::setProuductId(int id){

			if(id>0)


		productId=id;

			else

				cout<<"please Enter acorrect number"<<endl;

			}


		int Product::getprouductId (){


			return productId

		}




		string Product::setProductName(string name){

			int x=name.length();

			if (x>5&&x<30)

				productName=name;

				

			else 

				cout<<"set the name letters <30 and >5"<<endl;

		}


		string Product::getProuductName(){

			return productName;

		}

		double Product::setProductPrice(double price){

			if(price>0)

				productPrice=name;

			else

				cout<<"please Enter the price correctly"<<endl;

		}

		double Product::getProductPrice(){

			return productPrice;

		}


			





	#ifndef PRODUCTCATALOG_H

	#define PRODUCTCATALOG_H

	#include <iostream>


	#include<string>

	#include"product.h"


	using namespace std;



	class ProductCatalog{

	public:

		ProductCatalog();



		Product productList[10];

	void loadProducts();

	int getProductcount(int);

	void addProduct(int,string,double);

	void displayProducts();



	private:

		int productCount;};

		



	#endif


#include <iostream>

using namespace std;

#include<string>

#include"product.h"

#include <fstream>

#include "ProductCatalog.h"



ProductCatalog::ProductCatalog(){


productCount=0;

loadProducts;

}

void ProductCatalog::loadProducts(){


	string line;

ifstream myfile ("products.txt");

if (myfile.is_open())

{

while (! myfile.eof() )

{

getline (myfile,line);

Product prod(line);

productList[productCount]=prod;

productCount++

}

myfile.close();

}



void ProductCatalog::displayProducts(){

	for (int j=0;j<productCount;j++)

		cout<<productList[j].callTostring();

}

int ProductCatalog::getProductcount(int id)

{

	for(int i;i<productCount;i++)

		if (id==productList[i].getprouductId)

			return productList[i];

}




void ProductCatalog::addProduct(int id ,string name,double price ){


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


{


if(id==productList[i])


{


cout<<"this product already Exists";


break;


            }


else


{


                Product prod = Product(id,name,price);


productList[i]= prod;


}


}


}



	


	#ifndef SHOPPINGCARD_H

	#define SHOPPINGCARD_H



	#include <iostream>

	#include<string>

	#include"product.h"

	#include"ProductCatalog.h"

	#include <fstream>

	using namespace std;



	class ShoppingCard {

	private:



	ProductCatalog shoppingList[10];


	ProductCatalog productCount;

	public:

		ShoppingCard();

		int totalShoppingAmount;


	void addProduct(Product);


	Product getTotalShoppingAmt(Product);

	void displayShoppingCard();

	int getChange(int,int);


	void saveShoppingList();




	#endif


			#include <iostream>

			using namespace std;

			#include<string>

			#include"product.h"

			#include "ProductCatalog.h"

			#include "ShoppingCard.h"

			#include <fstream>


			ShoppingCard::ShoppingCard (){


				productCount=0;

			}



			void ShoppingCard:: addProduct(Product item ){

			 Product prod = Product(id,name,price);

				do{

					cout <<"\n";

					cout <<" Please enter the product Id ( or 0 to go to checkout ):  " ;

					cin >> productId;

					if ( productId < 0 || productId > 6)

						cout << " !! Please enter a valid product Id or 0 to exit !! \n\n";

					else

						if (productCount<0)

							             


			productList[i]= prod;


						return shoppingList[10];

				} while (true);


			}






			void ShoppingCard::displayShoppingCard(){

				

				cout << " _________________________________\n";

				cout << "|         |             |         |\n";

				cout << "|   Id    |    Item     |  Price  |\n";

				cout << "|_________|_____________|_________|\n";

				cout << "|   1     |    Bread    |     5   |\n";

				cout << "|   2     |    Oil      |     8   |\n";

				cout << "|   3     |    Pizza    |    43   |\n";

				cout << "|   4     |    Laptop   |  1199   |\n";

				cout << "|   5     |    Macaroni |    20   |\n";

				cout << "|   6     |    Tuna     |     7   |\n";

				cout << "|_________|_____________|_________|\n";

			}






				ShoppingCard::getTotalShoppingAmt(){

					int *total;//pointer to total amount 

					int totalShoppingAmount=0;

			for(int i;i<10;i++)

			totalShoppingAmount=shoppingList[i].getProductPrice();


			  totalShoppingAmount++;

			        


					 cout <<" The total price is QR " << totalShoppingAmount << "\n";


				}

					


					product ShoppingCard::getChange ( int *total , int paidAmount ){

			{

				int change = paidAmount - *total;


				cout << "Your change is  : QR  " << change << " and I will give you : \n ";


				// Calculate bills to give back to the customer ...


				if ( change >= 500 )

					cout << change / 500 << " x 500 QR\n " ;

					change %= 500;


				if ( change >= 100 )

					cout << change / 100 << " x 100 QR\n " ;

					change %= 100;


				 if ( change >= 50 )

					cout << change / 50 << " x 50 QR\n " ;

					change %= 50;


				 if ( change >= 10 )

					cout << change / 10 << " x 10 QR\n " ;

					change %= 10;


				 if ( change >= 5 )

					cout << change / 5 << " x 5 QR\n " ;	

					change %= 5;


				 if ( change >= 1 )

					cout << change << " x 1 QR\n " ;

			}



			void ShoppingCard::saveShoppingList(){

				 ofstream shoppingListFile("shoppinglist.txt");

			  //or just delcare the variable: ofstream myofile 

			  shoppingListFile.open("shoppinglist.txt");

			  if (shoppingListFile.is_open())

			  {

			for(int i;i<10;i++)

					shoppingList<< shoppingList[i]<<"/n";

					shoppingListFile.close();

			  }







the main
	

	// ----------------------------------------------------------------

	#include <iostream>

	#include <string>

	#include <fstream>

	#include"product.h"

	#include "ProductCatalog.h"

	#include"ShoppingCard.h"


	using namespace std;

	            


	int main ()

	{

		int amountPaid;

	shoppingCard user1;


	user1.displayShoppingCard();

	user1.addProduct();

	user1.getTotalShoppingAmt();

	cout<<"please Enter the Mony:";

	cin>>amontPaid;

	user1.getChange(int*total,int amountPaid);


	cout<<"Thank you for visit our shop";

	user1.saveShoppingList();


	}



#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Can you post the exact error? Which file is not found? Is it a compile-time error or a run-time error? etc. etc. etc.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
Q-Girl

Q-Girl

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Idon't Know I have this message
Posted Image

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
That looks like it's compiling, but not in the expected location, or that there may have been a compiler error.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog