Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

My C++ program


ghost's Avatar
0 0

I'm making a program in C++ for my coomputer project..for Cambridge exams….

I got the feeling it pretty sucks… Anyone could give me ideas to make it better?????

"Supposed to be record oriented"

…Supposed to include array and a search function….

// 3.cpp : main project file. P2 Computing Project …C++

#include "stdafx.h" #include "stdlib.h" #include "time.h" #include <sys/types.h> #include <sys/timeb.h> #include <stdio.h> //Returns values to the progra fo the Date function #include <iostream> #include <string.h> using namespace std;

int main() { //main declarations char name[30]; char address[35]; char gender; char team; char project[30]; char department; float number_project_completed; float sales_pro;//sales made from the totality of projects float rank;//an assignment for the renk which the person possese within the company. The smallest number representing the most important

//Declarations for time reading and displaying
char tmpbuf[128], timebuf[26], ampm[] = &quot;AM&quot;;
time_t ltime;
struct _timeb tstruct;
struct tm today, gmt, xmas = { 0, 0, 12, 25, 11, 93 };
errno_t err;



cout&lt;&lt;&quot;&#92;n================================================================================&quot;;
cout&lt;&lt;&quot;			 program				S.P&quot;;
cout&lt;&lt;&quot;&#92;n================================================================================&quot;;

// Set time zone from TZ (Time Zone) environment variable. If TZ is not set,
// the operating system is asked to obtain the default value 
// for the variable in order to find the time. 
//
_tzset();

// Displaying operating system-style date and time. in this case, that of Windows XP
_strtime_s( tmpbuf, 128 );
printf( &quot;&#92;n time:&#92;t&#92;t&#92;t&#92;t%s&#92;n&quot;, tmpbuf );
_strdate_s( tmpbuf, 128 );
printf( &quot;&#92;n date:&#92;t&#92;t&#92;t&#92;t%s&#92;n&quot;, tmpbuf );

cout&lt;&lt;&quot;&#92;n--------------------------------------------------------------------------------&quot;;

cout&lt;&lt;&quot;&#92;n [If a statement appears several times, then you have surely made a mistake] &#92;n&quot;;


cout &lt;&lt; &quot;&#92;n Please enter name: &quot;;
cin &gt;&gt; name;
cout &lt;&lt; &quot;&#92;n Please enter address: &quot;;
cin &gt;&gt; address;

//Start of loop aiming at restricting values for "gender" //While loop do

{cout<<"\n Enter gender of employee:";
cout<<"Key in M for Male and F for Female: "; cin>>gender;

}  while (gender != &#39;f&#39;&& gender != &#39;m&#39;);
	
	if (gender == &#39;m&#39; )
	cout&lt;&lt;&quot;&#92;n You entered male&quot;;
	else 
		if (gender == &#39;f&#39;)
		cout&lt;&lt;&quot;&#92;n You entered Female&quot;;
cout &lt;&lt; &quot;&#92;n &quot;;

//Start of loop aiming at restricting values for "department" //While loop do

{cout&lt;&lt;&quot;&#92;n Enter Department. R: Research		D:	Development	&quot;;
cin&gt;&gt;department;

}  while (department != &#39;d&#39;&& department != &#39;r&#39;);
	//Capital letters not considered by program
	if (department == &#39;d&#39; )
	cout&lt;&lt;&quot;&#92;n You entered Development Department&quot;;
	else 
		if (department == &#39;r&#39;)
		cout&lt;&lt;&quot; &#92;n You entered Research Department&quot;;
	
cout&lt;&lt;&quot;&#92;n&quot;;

// Start of loop aiming at restricting values for "team"

do {cout<<"\n Enter Team. a: Team Alpha o: Team Omega "; cin>>team; } while (team != 'a'&& team != 'o');

		if (team == &#39;a&#39; )
		cout&lt;&lt;&quot;&#92;n You entered Team Alpha&quot;;
		else
			if (team == &#39;o&#39; )
			cout&lt;&lt;&quot;&#92;n You entered Team Omega&quot;;


cout&lt;&lt;&quot;&#92;n&quot;;

cout&lt;&lt;&quot;&#92;n Enter Project the person is responsible of :&quot;;
cin&gt;&gt;project;
cout&lt;&lt;&quot;Project name is: &quot;&lt;&lt;project;

cout&lt;&lt;&quot;&#92;n Enter number of projects completed by the employee: &quot;;
cin&gt;&gt;number_project_completed;
cout&lt;&lt;&quot;The employee has acheived &quot;&lt;&lt;number_project_completed&lt;&lt;&quot; projects &quot;;

return 0; }


ghost's Avatar
0 0

Sorry I can't help but I thought people of a high interlect get accepted into Cambridge… I saw one question but more than one question mark.

Plus don't you get a tutor you could be asking?


ghost's Avatar
0 0

I'm not at Cambridge…

Just taking part in the A Level International Exams

The person who's supposed to help me doesn't know well C++…

And I think she's constanly suffering from hormonal problems… ….no matter what shithappens to me SHE WON'T HELP……


bl4ckc4t's Avatar
Banned
0 0

It seems like it will work, I compiled it and it ran fairly smooth, I didnt notice anything wrong. The best thing is to save the source and compile.

Also, if you want to see if your doing something wrong in programming, get notepad++ it has support for pretty well all the languages and highlights syntax, and numbers lines, etc.

download it at: http://notepad-plus.sourceforge.net/uk/site.htm

Bl4ckC4t


ghost's Avatar
0 0

Yeah..I know it works..the problem is that it is too simple and i'm not going to be awarded many marks with such a rudimentary program,…I need to upgrade it in some way. My inspiration has run dry!!!!


ghost's Avatar
0 0

So you want to make it more complicated by doing what? Adding new functions to it or just creating a fuck job mess of the code? If its the later of the two leave your code alone.


ghost's Avatar
0 0

I need to be "oustanding"…..

this program is so….berrrrk!!

I need to be able to save and search records…

How???


ghost's Avatar
0 0

The syllabus says that the following skills should be demonstrated: arrays and/or records different data types [got it] selection iteration [got it] procedures functions searching techniques files


ghost's Avatar
0 0

You should be able to use some functions in there pretty easily, returning the character strings. And as for files (assuming you mean reading from files to get the information instead of command-line), you should be able to change that without changing much of the code. Would you want to get the information from one file or several files?


ghost's Avatar
0 0

only one


ghost's Avatar
0 0

?????????????????????????????????? ?????????anyone can help??????????? ?????????????????????????????


lukem_95's Avatar
Member
0 0

no offence but for a Cambridge level program, thats not the best, im a 14 year old kid ( and funnily enough live in Cambridge :P ) and that program isnt really inspiring lol, i could write better, maybe you should try something more interesting than simple cin and cout stuff (althought all the dates etc is pretty cool, i havnt seen that before).


lukem_95's Avatar
Member
0 0

no offence but for a Cambridge level program, thats not the best, im a 14 year old kid ( and funnily enough live in Cambridge :P ) and that program isnt really inspiring lol, i could write better, maybe you should try something more interesting than simple cin and cout stuff (althought all the dates etc is pretty cool, i havnt seen that before).


ghost's Avatar
0 0

If you think you can make it better, feel free to do so…

pm me if you got any ideas..or post it here..


ghost's Avatar
0 0

Anyone?? Please!! No one really competent on this site???????????


ghost's Avatar
0 0

People have helped you as much as they can. I haven't seen on post of appreciation.

Either start something more constructive or go elsewhere.

If you continue to duplicate posts then this thread will be locked.