User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,692 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,746 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 1595 | Replies: 1
Reply
Join Date: Oct 2005
Posts: 20
Reputation: ToySoldier is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
ToySoldier's Avatar
ToySoldier ToySoldier is offline Offline
Newbie Poster

My 1st C++ program advice needed

  #1  
Oct 2nd, 2005
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;
}
<< moderator edit: added [code][/code] tags >>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Posts: 20
Reputation: ToySoldier is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
ToySoldier's Avatar
ToySoldier ToySoldier is offline Offline
Newbie Poster

Re: My 1st C++ program advice needed

  #2  
Oct 3rd, 2005
Originally Posted by ToySoldier
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...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 8:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC