1. User will enter the ISBN,
The system will trace the title and price of the book automatically.
The system should check whether the book is in the stock or not.
If it is not, please let the user to enter again.

2. Allow a customer to buy more than one item from the bookshop.

3. Calculate and print the bill.
The billing amount should include 5% tax.

Sample Output:

Welcome to Jack’BookShop

Please enter the ISBN: 1234
The title is Introduction to Java Programming
The Price is RM 99.50

Do you wish to continue? y/n
y

Please enter the ISBN: 5678
The title is C++ How to Program
The Price is RM 79.40

Do you wish to continue? y/n
n

Your Receipt:

1234 RM 99.50
5678 RM 79.40
Total RM 178.90
Tax RM 8.95

Total RM 187.85

Thank You!!!
Please Come Again!!!

Source Code..which i have do some..anyone can add or modify it??
and correct the mistakes if possible..

Help :cry: i cant solve it... :cry:

#include <iostream> 
#include <fstream>
#include <iomanip>

using namespace std;

int main()
{ 
    double ISDN ; 
    char title;
	float price;
	int continues;
	char ans;
	 
	cout<<"---Welcome To Billy's Bookshop---\n";
	cout<<"Please enter the ISDN: ";
	cin>>ISDN;

	if (ISDN==1234)
	{
		cout<<"The Title is Introduction to Java Programming"<<endl<<"The Price is RM 99.50"<<endl;
	}
    if (ISDN==5678)
	{
		cout<<"The Title is C++ How to Program"<<endl<<"The Price is RM 79.40"<<endl;
	}
	else
	{		
		cout<<"Not Valid"<<endl;
	}

	
	do
	{
       cout<< "Do you want to continue (Y/N)?\n";
       cout<< "You must type a 'Y' or an 'N'.\n";
       cin >> ans;
	}
	while((ans !='Y')&&(ans !='N')&&(ans !='y')&&(ans !='n'));

	
	return 0; 
}

You've got the right idea, and you are really close. Try moving the start of the "do" block to before requesting the ISDN number but after printing the title. After you fix up your loop, we can work on the totals if you need help with that.

go for switch case rather than if-else blocks

how do you know whats in stock? do you read that info from a file? you gotta enter it by hand?

You can use the STL to simplify your exercise.

I would probably use a sorted vector of structs(or a map) with 5 members(isbn,author,title,price,num_copies_instock) to represent the stock. If you keep it sorted by isbn you will get fast searches using a binary search algorithm. Then get entry by isbn and try find it in the vector. If entry exists then add to receipt. This can be another vector. If not say something like we dont have it etc.. At end of user input receipt can be printed by iterating thru the receipt vector.

You familiar with structs? std::string? std::vector? std::map?

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.