Hey all,
I am working on my first C++ prog and I'm having an issue on my output. I compiled the code ok but when i try to execute, the output comes up with weird numbers and letters where it is supposed to display the "photos in"
// Name: Danny Delgado
// Course: CIS-165
// Last Update: 2/21/2012
// Description: Moreprints Photo Prints
//*********************** Preprocessor Directives *********************
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <stdlib.h>
using namespace std;
//******************************* main ********************************
int main(void)
{
double photos, // photos entered by customer
reprints, // reprints submitted by customer
total_photos, // total photos calculated product of photos x reprints
cost_prints, // total photos x .50
tax_total, // cost of prints * .07
price_total, // cost_prints + tax_total
tax_rate = .07, // tax rate
price_per = .50, // price per photo
choice;
string name; // entered name
char drive[2],
disk_file[15],
file[9];
ofstream outfile;
// input section
system ("cls"); // clear the screen
cout << "please enter your first and last name" << endl;
cin >> name;
cout << "please enter number of photos" << endl << endl;
cin >> photos;
cout << "please enter reprints submitted" <<endl;
cin >> reprints;
// process section
total_photos = photos * reprints;
cost_prints = total_photos * price_per;
tax_total = cost_prints * tax_rate;
price_total = cost_prints + tax_total;
// output section
system ("cls");
cout << "Output to console (1) or disk file (2): ";
cin >> choice;
if ( choice == 1 )
{
system ("cls");
outfile.open("con");
}
else //routine allows interactive entry of external file name
{
cout << "Which drive: a, b, c, d, e, or f ? ";
cin >> drive;
strcpy(disk_file, drive);
strcat(disk_file, ":");
cout << "Enter a results file name: ";
cin >> file;
strcat(disk_file, file);
strcat(disk_file, ".dta");
outfile.open(disk_file);
}
outfile << setiosflags(ios::showpoint | ios::fixed) << setprecision(2);
outfile << "MOREPRINTS Photo Store" << endl;
outfile << "======================" << endl;
outfile << "Customer Name " << name << endl;
outfile << "Photos In " << photos <<
outfile << "Reprints Ordered " << reprints << endl;
outfile << "total reprints " << total_photos << endl;
outfile << "Price/Reprint " << price_per << endl;
outfile << "Reprint Cost " << cost_prints << endl;
outfile << "Tax " << tax_total << endl;
outfile << "Total Cost " << price_total << endl;
outfile << "photos " << photos << endl;
outfile.close();
cout << endl << endl; // provides blank line before pause display message
system ("pause");
return 0;
}