Hey, I really need some help fixing the errors in this source file!
I honestly don't know how to fix some of the errors. This assignment has to be submitted it 2 days. I've looked for the missing sytax errors and the other ones but i just cant seem to fix them. Thanks in advance for any help that can be given.

// Filename: Coding Assignment - Source File 1
// Author: Damien O'Neill
// This program illustrates a menu system with the use of a function to display menu choices


//Below are the libraries included in this file.

#include<conio.h>
#include <string.h>
#include<iomanip.h>
#include "windows.h"
#include "stdio.h"
#include <process.h>
#include <fstream.h>

//Below are the functions.

void menu_display(char product_info[8][65],double price_info[8],int max_items);
void swap(char user_choice[40][65],char product_info[8][65],double price_info[8],int max_items);

// As you can see I have allowed 65 characters for each description and a maximum of 8 items in each menu.


ofstream outfp;		//This is to write the file


//Below are the arrays and items included that the user can select.


char Graphics[8] [65]={"768MB-Nvidia-FX4600-Graphics Card-Dual DVI/Dual VGA-Kit",
						"Dell-DVI Adapter Card-Low Profile-Kit",
						"3D Fuzion 3DFR76256GSE GeForce 7600GS 256MB PCI-E Graphics Card",
						"BFG Technology AGEIA 128MB PCI Physx Card"};
double Graphics_price[8]={1511.05,19.98,49.97,59.97};


char Motherboard[8][65]={"ECS RS485M-M v1.0 AM2 MATX Motherboard",
						"NFM2S WI-FI AM2 MATX MOTHERBOARD",
						"PENTIUM D 820 PROCESSOR + FOXCONN 945GZ7MC 775 ATX MOTHERBOARD",
						"INL INT E4300 FCN 945"};
double Motherboard_price[8]={49.97,69.99,109.98,149.99};


char CPU[8][65]={"ATHLON 64 X2 5200+ SOCKET AM2 PROCESSOR",
				"ATHLON 64 X2 6000+ SOCKET AM2 PROCESSOR",
				"CORE 2 DUO E6400 LGA775 PROCESSOR",
				"CORE 2 DUO E4400 SOCKET LGA775 PROCESSOR"};
double CPU_price[8]={99.99,149.99,139.99,79.98};


char HardDisk[8][65]={"400GB 3.5 SATA INTERNAL",
						"250GB 3.5 PATA INTERNAL",
						"80GB 2.5 PATA INTERNAL HARD DISK DRIVE",
						"Hitachi 120GB 2.5 Internal Hard Disk Drive"};
double HardDisk_price[8]={68.99,47.99,39.99,44.99};


char Sound[8][65]={"X-FI FATAL1TY GAMER PRO SOUNDC",
					"X-FI XTREME GAMER SOUNDCARD",
					"CREATIVE SOUNDBLASTER CONNECT",
					"5.1 PCI SOUND CARD"};
double Sound_price[8]={109.99,54.99,19.99,7.05};


char Memory[8][65]={"1GB PC2700 DDR SODIMM MEMORY",
					"512MB PC133 SDRAM DIMM MEMORY",
					"256MB PC133 SDRAM DIMM MEMORY",
					"512MB PC2100 DDR SODIMM MEMORY",
					"256MB PC100 SDRAM SODIMM MEMORY",
					"256MB PC133 SDRAM SODIMM MEMORY",
					"512MB PC2-6400 *GOLD* DDR2 DIMM MEMORY",
					"2512MB PC2-4300 DDR2 DIMM MEMORY"};
double Memory_price[8]={59.99,34.99,22.99,24.99,49.97,19.99,19.99,14.99};


char Storage[8][65]={"PIONEER BLU-RAY DISK DRIVE PC",
					"LITEON LH-20A1P INTERNAL 20X DVD REWRITER",
					"LG GSAH42L INTERNAL 18X DVD-RW",
					"EMPREX  DVDRW2016IM 16x MULTI FORMAT INTERNAL DVD REWRITER"};
double Storage_price[8]={149.99,29.99,29.99,29.99};


char OperatingSystem[8][65]={"MICROSOFT VISTA ULTIMATE 32 BIT OEM",
							"MICROSOFT VISTA HOME PREMIUM",
							"MICROSOFT VISTA HOME BASIC",
							"MICROSOFT HOME PREMIUM 32 BIT OEM"};
double OperatingSystem_price[8]={119.99,199.99,179.99,69.99};


char Product[8][65]={"DESKTOP CASE or MINITOWER CASE"};
double Product_price[8]={29.99};



//Initialise the Global Arrays and  Global Variables


char user_choice[40][65]={""};		//This reserves some space for the products the user has chosen.
double user_price[40]={0};			//This reservers some space for the corrisponding product prices. 
int user_qty[40]={0};				//This reserves some space for the quantity That the user wants.
int customer ,qty =0;
double	total=0.0;
double	vat=0.0;
double	o_total=0.0;



void main()
{
	int max_items=0;


//This code displays the menu choices //The parameters are replaced by the arrays containing the data.

outfp.open("invoice.txt" , ios::out);


menu_display(Graphics,Graphics_price,4);
menu_display(Motherboard,Motherboard_price,4);
menu_display(CPU,CPU_price,4);
menu_display(HardDisk,HardDisk_price,4);
menu_display(Sound,Sound_price,4);
menu_display(Memory,Memory_price,8);
menu_display(Storage, Storage_price,2);                  
menu_display(OperatingSystem,OperatingSystem_price,4);				 
menu_display(Product,Product_price,1);

cout<< "Thankyou very much";


//Output what the user/customer has selected

system ("cls");

cout<<"These are your choices!\n";

cout<<"No	"<<"qty		"<<"Item chosen	"<<"Item price "<<"\n\n";

for (int count=0;count<customer;count++);
{
cout<<setw(2)<<count<<setw(2)<<user_qty[count]<<setw(65)<<user_choice[count]<<setw(9)<<user_price[count]"\n";

total=total+ (user_qty[count]*user_price[count]);

outfp<<setw(2)<<count<<setw(2)<<user_qty[count]<<setw(65)<<user_choice[count]<<setw(9)<<user_price[count]"\n";


}

outfp<<"Total = "<<total;
cout<<"Total = "<<total;
return;
}


//The function below displays the menu choices

void menu_display(char product_info[8][65],double price_info[8],int max_items);
{
int no_items;
int again ,choice;


cout<<"\n\n\n               ***PC Building Blocks***             \n\n\n";

for (no_items=0;no_items<max_items;no_items++)
            {
	    cout<<setw(2)<<no_items<<setw(65)<<product_info[no_items]<<""<<setw(9)<<price_info[no_items]<<"\n\n";
	}
	return;
}

do{
	do{
		cout<<"Can you please enter your product number = ";
			cin>>choice;
		     }while ((choice<0)  || (choice>3));

	swap(user_choice,product_info,price_info,choice;

		      
	cout <<"How many would you like?= ";
		      cin>>qty;
cout <<"If you would like another go Press 0, If you would like to move on Press 1";
		    cin >>again;


   }while (again==0);

	system ("cls");   
	
	return;
}


{
	void swap(char user_choice[40][65],char product_info[8][65],double price_info[8],int max_items);

	strcpy(use_choice[customer],product_info[choice]);
	user_price[customer]=price_info[choice];
	user_qty[customer]=qyt;
return;
}

Recommended Answers

All 5 Replies

Use [code]

[/code] tags, otherwise you likely won't get much help... see here.

Edit: Narue edited post to include tags just as I wrote this.. Ah well see above for future reference! :D

commented: Agreed :) +7

What errors do you get from the compiler ?

Line #172 and below: statements outside function body... Where is this function header?

while you are fixing this. Please note that you often write

for (int count=0;count<customer;count++);
   {
      // Stuff
   }

Observe the semi colon after the for loop that should not be there since the body is not going to get executed until after the pointless loop. gcc gives warnings about this, as I expect every other modern compiler does, so please fix both errors AND warnings unless you are really absolutely certain the warnings are harmless. [Even then I fixe them to avoid output noise].

commented: Good observation! +8

Line 108 - void main() to which main() returns an int & should be declared as such. (return statements should return a value, in the case of main() an int) See here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.