help with project

Hello everyone. I am writing this because I need some help. I am taking programming I class and I am having problems with this program I wrote and can't figure out how to fix it. I have spent about 2 weeks , off and on, trying to fix it and can't figure it out. The problem is that you cannot enter the title or the isbn to the book. When you loop it, it will not let you enter the date along with the isbn and title.


I attach a copy the program below. Any help will be greatly appreciated.



Comments

  • [color=Blue]I do not see any attachment.[/color]
  • Sorry here is the code. I thought it got attached.

    // This program displayes the cashier screen

    #include
    #include
    using namespace std;

    int main()
    {
    char date[9];
    char isbn[25];
    char title[25];
    char again;
    int quantity;
    double unitPrice, total, subTotal,tax;
    do
    {
    //Inputs for sales slip
    cout << "Please input the date in the format MM/DD/YY.
    ";
    cin.getline(date,9);
    cout << "How many copies of a book is being purchased.
    ";
    cin >> quantity;
    cout << "What is the ISBN number of the book.
    ";
    cin.getline (isbn,25);
    cout << "What is the price of the book.
    ";
    cin >> unitPrice;
    cout << "What is the title of the book.
    ";
    cin.getline(title,25);
    // formula for cashier screen
    subTotal = quantity * unitPrice;
    tax = 0.06 * subTotal;
    total = subTotal + tax;
    // Final display Title
    cout << " Serendipity Booksellers

    "
    << "Date: " << date <<endl << endl
    << "Qty" << " ISBN" << " Title" << " Price" << " Total
    "
    << "_________________________________________________________________________
    ";
    // Display inputs
    cout << quantity << " " << isbn << setw(27) << title <<" " << unitPrice;
    cout << " " << setprecision(2) << fixed << subTotal << endl << endl << endl;
    cout << " Subtotal " << setprecision(2) << fixed << subTotal << endl;
    cout << " Tax " << setprecision(2) << fixed << tax << endl;
    cout << " Total " << setprecision(2) << fixed << total << endl << endl;

    // Thank you line
    cout << "Thank you for shopping at Serenipity!
    ";

    // Does the user have another transaction to be processed
    cout << "Do you Have another transaction to be processed? (Y/N)
    ";
    cin >> again;
    } while ( again == 'Y' || again == 'y');
    return 0;
    }
  • Just use getchar() at the places indicated and your code should work like a charm.



    [code]
    #include
    #include
    using namespace std;

    int main()
    {
    char date[9];
    char isbn[25];
    char title[25];
    char again;
    int quantity;
    double unitPrice, total, subTotal,tax;
    do
    {
    //Inputs for sales slip
    cout << "Please input the date in the format MM/DD/YY.
    ";
    cin.getline(date,9);
    cout << "How many copies of a book is being purchased.
    ";
    cin >> quantity;
    [color=Blue]getchar();[/color]
    cout << "What is the ISBN number of the book.
    ";
    cin.getline (isbn,25);
    cout << "What is the price of the book.
    ";
    cin >> unitPrice;
    [color=Blue]getchar();[/color]
    cout << "What is the title of the book.
    ";
    cin.getline(title,25);
    // formula for cashier screen
    subTotal = quantity * unitPrice;
    tax = 0.06 * subTotal;
    total = subTotal + tax;
    // Final display Title
    cout << " Serendipity Booksellers

    "
    << "Date: " << date <<endl << endl
    << "Qty" << " ISBN" << " Title" << " Price" << " Total
    "
    << "_________________________________________________________________________
    ";
    // Display inputs
    cout << quantity << " " << isbn << setw(27) << title <<" " << unitPrice;
    cout << " " << setprecision(2) << fixed << subTotal << endl << endl << endl;
    cout << " Subtotal " << setprecision(2) << fixed << subTotal << endl;
    cout << " Tax " << setprecision(2) << fixed << tax << endl;
    cout << " Total " << setprecision(2) << fixed << total << endl << endl;

    // Thank you line
    cout << "Thank you for shopping at Serenipity!
    ";

    // Does the user have another transaction to be processed
    cout << "Do you Have another transaction to be processed? (Y/N)
    ";
    cin >> again;
    } while ( again == 'Y' || again == 'y');
    return 0;
    }[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories