| | |
Help with "simple for some" c++ output problem..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 17
Reputation:
Solved Threads: 0
Hello,
I am having trouble with one of my assignments and was hoping someone could help explain why this problem is occurring.
The following code is set up to ask the user if they would like another transaction after they have completed the program. The first time the user inputs data the output stays in its proper format, but if the user elects to perform another transaction the table in the output is manipulated..
Here is the code and below it is a description of the problematic output ...
Help would be greatly appreciated and any advice on how I have written the code or about anything is greatly appreciated ..
In the first iteration The table headings(Qty,ISBN,Title,Price,Total) are spaced properly
In any additional iteration the table headings scrunch up to the left ...
Can someone please help.
Thanks !
Colin
I am having trouble with one of my assignments and was hoping someone could help explain why this problem is occurring.
The following code is set up to ask the user if they would like another transaction after they have completed the program. The first time the user inputs data the output stays in its proper format, but if the user elects to perform another transaction the table in the output is manipulated..
Here is the code and below it is a description of the problematic output ...
Help would be greatly appreciated and any advice on how I have written the code or about anything is greatly appreciated ..
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <iomanip> #include <cstring> using namespace std; int main () { //Use do to mark the start of the loop and introduce variable needed outside of loop scope. char additional_Transaction ; do { //Declaring variables char date[10]; int quantity; char isbn[18]; char title[35]; float price; //Asks the user to enter p.o.s data cout <<endl << "Please enter todays date in the following format"; cout << " MM/DD/YY: "; cin >> date; cout << endl; cout << "Please enter the quantity of the book being purchased: "; cin >> quantity; cout << endl; cout << "Please enter the books ISBN of the book being purchased: "; cin >> isbn; cout << endl; cin.ignore(); cout << "Please enter the title of the book being purchased: "; cin.getline (title, 35); cout << endl; cout << "Please enter the price of the book being purchased: "; cin >> price; cout << endl << endl; //Displays information entered by user cout << "Serendipity Booksellers\n Cashier Module" << endl << endl << endl; cout << "Date: " << date << endl ; cout << "Quantity: " << quantity << endl ; cout << "ISBN: " << isbn << endl ; cout << "Title: " << title << endl ; cout << "Price: $" << price << endl ; //Introducing new variables, and performs calculations float subtotal = price + quantity ; double tax = subtotal * .06 ; float total = subtotal + tax ; //Displays information cout <<endl <<endl << "\t\t\t\t Serendipity Booksellers" <<endl; cout <<endl <<endl << "Date:" << date <<endl <<endl; cout << "Qty" << setw(9) << "ISBN" << setw(16) << "Title" << setw(25) <<" Price" << setw(20)<< "Total" <<endl; cout <<"__________________________________________________________________________________________" <<endl; cout << quantity << " " ; cout << setw(15) << left << isbn ; cout << setw(26) << left << title ; cout << setprecision(2) << fixed << showpoint << "$" << price ; cout << setprecision(2) << fixed << showpoint << " $" << left << total ; cout <<endl <<endl <<endl << setprecision(2) << showpoint << fixed <<" Subtotal $ " << subtotal <<endl; cout << setprecision(2) << fixed << showpoint <<"\t\t Tax $ " << tax <<endl; cout << setprecision(2) << fixed << showpoint <<"\t\t Total $ " << total <<endl <<endl; cout <<endl << "\t Thank You for Shopping at Serendipity!" <<endl <<endl; cout << "\t Would you like to preform another transaction? "; cin >> additional_Transaction; cout << endl << endl; //Declare the conditions of the loops repeat execution with while }while ( additional_Transaction == 'Y' || additional_Transaction == 'y' ); //Output for program exit cout << "\t Thank You, have a nice day.\n"; return 0; }
In the first iteration The table headings(Qty,ISBN,Title,Price,Total) are spaced properly
In any additional iteration the table headings scrunch up to the left ...
Can someone please help.
Thanks !
Colin
![]() |
Similar Threads
- Vector Output Problem (C++)
- "simple" file parser i am making (Python)
- google "keyword" question (Search Engine Optimization)
- so-called "simple" host (Web Hosting Deals)
Other Threads in the C++ Forum
- Previous Thread: Need help to create a main driver in c++
- Next Thread: Loan Program
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






