0

Hi... thru trial & error.. I managed to get my homework program to compile. However I'm pretty sure I did it the long way :-| . Can someone give me a direction to make it easier? Brand new to C++ so bear with me. I have enough to make the teacher happy but I'm not. I copy and pasted my source code directly from Visual C++ 6.0:

How do I get my output to print on my printer? All I see is a "DOS" type screen popup which does not give me an option to print it. I suppose I could ask my teacher tomorrow but it would be great if I didnt have to.

// Assignment #1 due 4 Oct 2005
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

const double taxes = 1.05; // Sales Tax 5%

const string c1="BREAKFAST-CAFE ",c2="SALADS-ARE-US",c3="WRONG-WAY-INC", // Customer Names
c4="BUGS-BUNNY",c5="HAWAII-50",c6="HAPPY-HOUR-BAR",c7="CAMPELL-SOUP",
c8="CACTUS-JACK",c9="HEALTH-FOODS",c10="NO-WAY-TODAY",
c11="DOCTORS-AWAY",c12="DAN-TUCKER",c13="LAST-CHANCE"; // Customer Names

const string in1="ORANGES",in2="LETTUCE",in3="TURNIPS",in4="CARROTS",in5="PINEAPLES", // Item Names
in6="LIMES",in7="TOMATOES",in8="BEANS",in9="MELONS",in10="OKRA",in11="APPLES",in12="SQUASH",in13="ORANGES";

const int no1=100,no2=100,no3=99,no4=10,no5=125,no6=100,no7=750,no8=50,no9=100, // Number Ordered
no10=99,no11=900,no12=10,no13=100;

const double ip1=10.25,ip2=9.50,ip3=1.00,ip4=6.00,ip5=25.00,ip6=2.00,ip7=5.00, //Item Price
ip8=4.00,ip9=5.10,ip10=2.00,ip11=6.15,ip12=1.55,ip13=10.00;


int main()
{
    cout << left << setw(17) << "Customer Name" << left << setw(17) << "Item Purchased" << left << setw(10) // Names of Columns
        << "Subtotal" << left << setw(10) << "TOTAL w/Tax"
        << endl << endl; 

    cout << fixed << showpoint << setprecision(2); //print money fields to 2 places. Force Zero's and Decimal

    cout << left << setw(17) << c1 << left << setw(17) << in1 << left << "$" << setw(9) << (no1 * ip1)
        << left << setw(1) << "$" << (no1 * ip1) * taxes<< endl << endl;

    cout << left << setw(17) << c2 << left << setw(17) << in2 << left << "$" << setw(9) << (no2 * ip2)
        << left << setw(1) << "$" << (no2 * ip2) * taxes << endl << endl; 

    cout << left << setw(17) << c3 << left << setw(17) << in3 << left << "$" << setw(9) << (no3 * ip3)
        << left << setw(1) << "$" << (no3 * ip3) * taxes<< endl << endl;

    cout << left << setw(17) << c4 << left << setw(17) << in4 << left << "$" << setw(9) << (no4 * ip4)
        << left << setw(1) << "$" << (no4 * ip4) * taxes << endl << endl;

    cout << left << setw(17) << c5 << left << setw(17) << in5 << left << "$" << setw(9) << (no5 * ip5)
        << left << setw(1) << "$" << (no5 * ip5) * taxes << endl << endl;

    cout << left << setw(17) << c6 << left << setw(17) << in6 << left << "$" << setw(9) << (no6 * ip6)
        << left << setw(1) << "$" << (no6 * ip6) * taxes << endl << endl;

    cout << left << setw(17) << c7 << left << setw(17) << in7 << left << "$" << setw(9) << (no7 * ip7)
        << left << setw(1) << "$" << (no7 * ip7) * taxes << endl << endl;

    cout << left << setw(17) << c8 << left << setw(17) << in8 << left << "$" << setw(9) << (no8 * ip8)
        << left << setw(1) << "$" << (no8 * ip8) * taxes<< endl << endl;

    cout << left << setw(17) << c9 << left << setw(17) << in9 << left << "$" << setw(9) << (no9 * ip9)
        << left << setw(1) << "$" << (no9 * ip9) * taxes << endl << endl;

    cout << left << setw(17) << c10 << left << setw(17) << in10 << left << "$" << setw(9) << (no10 * ip10)
        << left << setw(1) << "$" << (no10 * ip10) * taxes << endl << endl;

    cout << left << setw(17) << c11 << left << setw(17) << in11 << left << "$" << setw(9) << (no11 * ip11)
        << left << setw(1) << "$" << (no11 * ip11) * taxes << endl << endl;

    cout << left << setw(17) << c12 << left << setw(17) << in12 << left << "$" << setw(9) << (no12 * ip12)
        << left << setw(1) << "$" << (no12 * ip12) * taxes<< endl << endl;

    cout << left << setw(17) << c13 << left << setw(17) << in13 << left << "$" << setw(9) << (no13 * ip13)
        << left << setw(1) << "$" << (no13 * ip13) * taxes << endl << endl;

    return 0;
}

Edited by happygeek: fixed formatting

1
Contributor
1
Reply
2
Views
11 Years
Discussion Span
Last Post by ToySoldier
0

Hi... thru trial & error.. I managed to get my homework program to compile. However I'm pretty sure I did it the long way :-| .

Okay..I managed to figure it out. I wasnt in class when he handed us a Text file... made my program MUCH easier to do...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.