ill post it all... :/
This is spree.cpp:
Code:
//Program Name: spree.cpp//
//Revision Date: 2002-11-08//
//Explanation: To create a shopping spree program//
#include <conio.h>
#include <iostream.h>
#include <string.h>
#include <iomanip.h>
#include "center.h"
#include <time.h>
#include <stdio.h>
#include "select.h"
#include "choice.h"
void fowler()
{
clrscr();
time_t t=time(NULL);
//Fowler Statement//
cout << setiosflags(ios::right|ios::fixed);
cout << setprecision(2) << endl;
cout << setw(79) <<ctime(&t)<< endl;
//Personal Center Function in "center.h" //
center("Shopping Spree Program",6);
center("~~~~~~~~~~~~~~~~~~~~~~",7);
cout << endl;
cout << "Explanation:" << endl;
cout << "~~~~~~~~~~~~" << endl << endl;
cout << "Using variables and while looping structures display the outcome of a shopping "<<endl;
cout << "spree. The following assignment will demonstrate a program structure, code "<< endl;
cout << "layout and use logic structures and looping structures.The program will use "<<endl;
cout << "data derived from a user and date acquired from the system at time of execution"<<endl;
center("Press Any Key To Continue...",17);
getch(); //Pause Screen//
clrscr(); //clear screen//
}
void input(char *first,char *last,double& winning_amount)
{
time_t t=time(NULL);
clrscr();
cout << ctime(&t) << endl;
center("Shopping Spree",3);
center("~~~~~~~~~~~~~~",4);
cout << endl;
cout <<"What is your name( first last): " ;
cin >>first;
cin >> last;
cout <<"How much won in contest: ";
cin >> winning_amount;
center("Press Any Key To Continue...",13);
getch();
clrscr();
}
int main()
{
double winning_amount = 200;
double total = winning_amount;
double nettotal;
menu(winning_amount,total,nettotal);
}
//variable declarations//
This is select.cpp and select.h:
Code:
#include "select.h"
#include <iostream.h>
#include <time.h>
#include <conio.h>
#include "center.h"
#include "choice.h"
void menu(double winning_amount, double total,double &nettotal)
{
int ch;
time_t t=time(NULL);
cout <<ctime(&t) << endl;
cout << endl;
center("Shopping Spree Program",3);
center("~~~~~~~~~~~~~~~~~~~~~~",4);
cout << endl;
cout << "a.\tComputer Shop" << endl;
cout << "b.\tTotal" << endl;
cout << "c.\tQuit" << endl;
for(/*forever*/;((ch = getch()) != EOF);)
switch(ch)
{
case 'a' :
choicecomp(winning_amount,total,nettotal);
break;
default :
cout << "Bye Bye" << endl;
getch();
break;
}
}
Code:
#ifndef _SELECT_H
#define _SELECT_H
void menu(double winning_amount, double total,double &nettotal);
#endif
Next is choice.h and choice.cpp
Code:
#ifndef CHOICE_H
#define CHOICE_H
void choicecomp(double winning_amount, double total,double &nettotal);
#endif
Code:
#include "select.h"
#include "center.h"
#include <time.h>
#include <iostream.h>
#include <conio.h>
#include "section.h"
void choicecomp(double winning_amount, double total,double & nettotal)
{
double CompChoice;
do
{
time_t t=time(NULL);
center("Shopping Paradise - Winner's Circle",3);
center("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",4);
cout <<" 1.\tHard Drive" << endl;
cout <<" 2.\tFloppy Disk" << endl;
cout <<" 3.\tCD Burner " << endl;
cout <<" 4.\tBlank CDs " << endl;
cout <<" 5.\tMonitor " << endl;
cout <<" 6.\tSpeakers" << endl;
cout <<" 7.\tVideo Card" << endl;
cout <<" 8.\tGlass Case" << endl;
cout <<" 9.\tWireless Keyboard" << endl;
cout <<"10.\tWireless Mouse " << endl;
cout <<"11.\tComputer Table " << endl;
cout <<"12.\tWindows XP Home " << endl;
cout <<"13.\tMotherboard " << endl;
cout <<"14.\tRogers @Home Starter Kit " << endl;
cout <<"15.\tMicrosoft Works XP" << endl;
cout <<"16.\tBorland C++ v. 6.0" << endl;
cout <<"17.\tRouter" << endl;
cout <<"18.\tNetwork Hub + Ethernet Card" << endl;
cout << endl;
cout <<"What is your choice : ";
cin >> CompChoice;
if(CompChoice == 19)
menu(winning_amount,total,nettotal);
if(CompChoice == 1)
total = total - 50;
else if(CompChoice == 2)
total = total - 5;
else if(CompChoice == 3)
total = total - 100;
else if(CompChoice == 4)
total = total - 10;
else if(CompChoice == 5)
total = total - 40;
else if(CompChoice == 6)
total = total - 90;
else if(CompChoice == 7)
total = total - 80;
else if(CompChoice == 8)
total = total - 130;
else if(CompChoice == 9)
total = total - 20;
else if(CompChoice == 10)
total = total - 25;
else if(CompChoice == 11)
total = total - 175;
else if(CompChoice == 12)
total = total - 200;
else if(CompChoice == 13)
total = total - 10;
else if(CompChoice == 14)
total = total - 15;
else if(CompChoice == 15)
total = total - 30;
else if(CompChoice == 16)
total = total - 21;
else if(CompChoice == 17)
total = total - 19;
else if(CompChoice == 18)
total = total - 82;
else
cout << "Sorry, That is an Invalid Selection..." << endl;
clrscr();
cout<<total;
}
while(total > 0);
total = nettotal;
}
Finally, center.h...
Code:
#include <string.h>
#include <conio.h>
#include <iostream.h>
#ifndef _CENTRE_H
#define _CENTRE_H
void center(char txt[60], int height)
{
int number, spaces;
number = strlen(txt);
spaces = 40 - number/2;
gotoxy (spaces,height);
cout << txt << endl;
}
#endif
I really need help with this, i've been working on this for a while, im a beginner, and i cant get it to run... any help would GREATLY appreciated, i dont want to get discouraged, only been doing C++ for about 2 weeks.Thanks