i have been tryin' to run it... but it still doesn't work
i have been tryin' to run it... but it still doesn't work
Please post you code in code tags. Don't attach it.
Your problem is the cin of the string. You should use getline();
Though after the cin before it, you need to take the '\n' out of the buffer with this:Code:cin.getline(custname,50,'\n');
Code:cin.ignore();
Sent from my iPadŽ
wait so....where i am goin to put itcout << "Enter the day: ";
cin >> day;
Well... you could put it after every cin statement, but that's unnessasary because the extraction operator ( >> ) ignores leading whitespace. getline() doesn't. So you really only need this:
Code:cout << "Enter the year: "; cin >> year; cin.ignore(); // Take the newline cout << "Please enter your full name: "; cin.getline(cust_name,50,'\n'); // Read in a full string up to the newline
Sent from my iPadŽ
thank you
how do you u make da date on da output like this 02/25/06
and also when i run it ...after I enter the number of reprints ordered..the run program automically closed....thanks again...
Here is the whole program, for reference:
Code:/* Name: Jamilton Copyright: Author: Date: Description: */ //************************Preprocessor Directives********************* #include <iostream> #include <fstream> #include <string> #include <iomanip> //*****************************Main****************************** using namespace std; const double SALES_TAX = 0.06; //declaration of constant value const double REPRINTS = 0.50; int main () { char cust_name[50]; //customer first and last name char dummy; double total_reprints; double tax_amount; double reprint_cost; double total_cost; int photos_submitted; int reprints_ordered; int month; int day; int year; // input section cout << "Enter the month: "; cin >> month; cout << "Enter the day: "; cin >> day; cout << "Enter the year: "; cin >> year; cout << "Please enter your full name: "; cin >> cust_name; cout << "Enter the number of photos submitted: "; cin >> photos_submitted; cout << "Enter the number of reprints ordered: "; cin >> reprints_ordered; //compute total reprints total_reprints = photos_submitted * reprints_ordered; // compute reprint cost reprint_cost = total_reprints * REPRINTS; // compute tax tax_amount = reprint_cost * SALES_TAX; // compute total cost total_cost = reprint_cost + tax_amount; // output section cout << "MOREPRINTS PHOTO STORE" << endl <<endl; cout << "______________________" << endl <<endl; cout << "Date: " << month << "/" << day << "/" << year << endl; cout << "Customer Name: " << cust_name << endl; cout << "Photos In: " << photos_submitted << endl; cout << "Reprints Ordered: " << reprints_ordered << endl << endl << endl; cout << setiosflags(ios::fixed) << setprecision(2); cout << "Total Reprints: " << total_reprints << endl; cout << "Price/Reprint: " << REPRINTS << endl; cout << "Reprint Cost: " << reprint_cost << endl; cout << "Tax: " << tax_amount << endl; cout << "Total Cost: " << total_cost << endl << endl; cout << "Press any key to continue." << endl; return 0; }Try <iomanip>. setw().how do you u make da date on da output like this 02/25/06
You want to keep the window open so you can see its output? http://faq.cprogramming.com/cgi-bin/...&id=1043284385and also when i run it ...after I enter the number of reprints ordered..the run program automically closed....thanks again...
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
where i am gonna put dis code <iomanip>. setw().
Okay:
Code:#include <iomanip> cout << setw(2) << day << '/' << setw(2) << month << '/' << setw(2) << year << endl;
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
PROBLEM SPECIFICATION
The MOREPRINTS Photo Store needs a program to calculate a customer bill based on the number
of photos submitted and the number of reprints ordered. Reprints cost fifty cents a piece. The number
of reprints ordered will be the same for each photo submitted: example - 5 photos, 3 reprints would be
15 total reprints. Sales tax is 6%. The customer bill should include the customer's name ( first and last).
The number of photos submitted, the number of reprints ordered, total number of reprints made, the cost
per reprint, the total cost of reprints, tax, and total bill.
Input: Customer Name
Order Date (MM//DD/YY)
Number of Photos submitted
Number of reprints ordered
CONSTANT: Any Information that is given and that will not be changed by the entry of data or by
calculation.
Variables: Data that will be changed by data entry, data calculation, or data manipulation.
Calculations: Number of photos * number of reprints
Total reprints * cost per reprint,
Cost of reprints * tax percentag e
Cost of reprints + tax amount
Output: ALL inputs and calculated data.
well....is dat correct.....