Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can clear the entire screen using the cleardevice() function and redraw the square in a loop with the new positions.

Yes he could, but that's not what he wants to do. And it would look terrible and be awfuly sloooooow if there were a lot of graphics on the screen such as you might see in games.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To erase the square, redraw it in the same color as its background.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have a boss once that required comments on each and every line of code. He was not proficient in computer languages but wanted to read and understand their logic. Now that is overkill.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>just wondering if there is anymore documentation that I woould need?

don't know -- depends on your teacher's requirements.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Heh. On WinXP I got "Skipped unknown compression method." I thought it was just me. :lol: I can see the file names, but I can't unzip them. Or is this an NSA challenge? :p

Jeff

I just now unziped it without any problems using WinZip on XP. I don't have *nix computer so can not test it there.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you try any of these google links?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>'m having trouble unzipping it on Linux.
are you using gzip ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>what do I NEED TO POST?
well, what have you tried? you already said you figured out what you need to do -- thats a good start. Now try putting that down on paper, schetch out on paper what you need to accomplish. Not code at this point, but just ideas. Don't get overwhelmed with the assignment -- take it one small step at a time.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

thanks for the help but I kind of figured that out already! The probelm im finding is in coding it. thanks just the same

you must post your code -- no one can help you if you do not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not a pascal prpgrammer so I can't write the program for you, but it will be the same in any language.

First create three string objects called month, day and year then use substring (or something similar) that will extract the appropriate digits from the original string into each of the three objects. Next convert each of the three sub strings into integers. Finally check that the month is between 1 and 12, the day is between 1 and last day of the month.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

maybe this will help you

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

not sure if the week numbers are correct or not. The days are ok

This program calculates the weeknday, the first days in the year, the weeknday
n the month2 of the years, the week, with which the month2 starts
The week with that of the month2 finishes and the number of the weeks in the mo
th2.
please, enter the year and the month in which the above-mentioned data should b
 shown,
finally the calender will come out with month and days

please enter a year : 2000
please enter a month: 1
that date is valid
the fisrt day of a year 2000is a: Sa
 the fisrt day of that month is on: 52calendar week
the fisrt day of that month is: Sa
the number of that week is: 6
the week in the month2 end in this week: 57


We | 52 53  1  2  3  4
-----------------------------
Mo |     3 10 17 24 31
Tue |     4 11 18 25
Wed |     5 12 19 26
Thu |     6 13 20 27
Fr |     7 14 21 28
Sa |  1  8 15 22 29
So |  2  9 16 23 30
Press any key to continue . . .
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Jan 1954 -- Only the week numbers are incorrect, days are ok.

Dec 1953 -- everything looks ok

please give a year : 1953
please give a month: 12
that date is valid
the fisrt day of a year 1953is a: Thu1953
28

 the fisrt day of that month is on: 49calendar week
1953
28
the fisrt day of that month is: Tue
the number of that week is: 5
the week in the month2 end in this week: 53


We | 49 50 51 52 53
-------------------------
Mo |     7 14 21 28
Tue |  1  8 15 22 29
Wed |  2  9 16 23 30
Thu |  3 10 17 24 31
Fr |  4 11 18 25
Sa |  5 12 19 26
So |  6 13 20 27
Press any key to continue . . .
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I haven't had time to look at it today, but since I can not read a word of German I am probably not the best person to even try. I don't know if anyone else here read/write German or not. Or if you could translate the program into English ... :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I marked this thread Solved for you. Glad you found the solution. :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think it worked ok for me. I can't read German so I guessed at the prompts. Below for Jan 2000

Dieses Programm errechnet den Wochentag, des ersten Tages im Jahr, den Wochentag
 im Monat des Jahres, die Woche, mit der der Monat anfaengt
Die Woche mit dem der Monat endet und die Anzahl der Wochen im Monat.
bitte geben sie das Jahr und den Monat ein, in denen die o.g. Daten angezeigt we
rden sollen
Anschliessend wird der Kalender des Monats angezeigt
bitte geben Sie das Jahr ein: 2000
bitte geben Sie nun den Monat ein: 1
das Datum ist gueltig
der erste Tag des Jahres, 2000ist der: Sa2000
29
1999
28

 der erste des Monats liegt in der: 52Kalender woche
2000
29
der erste des Monats ist der: Sa
 die Anzahl der Wochen in dem Monat betraegt: 6
die Woche in der der Monat endet ist die Woche: 57


Wo | 52  1  2  3  4  5
-----------------------
Mo |     3 10 17 24 31
Di |     4 11 18 25
Mi |     5 12 19 26
Do |     6 13 20 27
Fr |     7 14 21 28
Sa |  1  8 15 22 29
So |  2  9 16 23 30
Press any key to continue . . .
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I compiled and ran the program -- I didn't get any runtime errors, but I only entered a couple time zones.

Your program is more than a little confusing. why are you putting just one character at a time in its own array element of query[] ? For example, if I enter 123 <Enter> the program puts query[0] = '1', query[1] = '2' and query[2] = '3'. Then if I enter 234 <Enter> the program puts query[3] = '2', query[4] = '3' and query[5] = '4'. At this point it has
query[0] = '1'
query[1] = '2'
query[2] = '3'
query[3] = '2'
query[4] = '3'
query[5] = '4'

Note that the above contain the ascii values for the numbers I entered, not the binary values. The letter '1' is NOT the same as the number 1. (google for "ascii chart" and you will discover why)

Next you extract the three values from the above array. '1', '2' and '3' are the first thee. Then you attempt to use them as the index into the db array. But db array has a maximum of 9 for each dimension, and you are attempting to access '1' (49 decimal).

You have an array overflow problem -- attemtping to access elements out of bounds. To correct this you need to convert the letters to binary. One way to do that is like this:

hundred=filtered[i] - '0';
ten=filtered[i+1] - '0';
one=filtered[i+2] - '0';
…
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The values you put in the array are not relevent to your problem. I suspect the actual error is elsewhere in your program because what you posted looks ok. Without more code its impossible to say what your problem is.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

please post how the array was declared, or better yet post the entire function. what's the max value of each dimension?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
{'J', 10},{'Q', 10},{'K', 10},
    {'A', 1}

The above are all wrong. the values of J, Q, K and A are incorrect, should be 11, 12 , 13 and 14 respectively.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think the Op's original problem has been solved -- see his post #5 and 6 to this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanks for reply. You are probably right that I'm missing some goodies staying with an old compiler, but I don't want the cost of a new one, or learning a new environment.
In spite of the bizarre error messages, it turned out to be a simple coding error.

cost is no excuse -- some such as Dev-C++ are free.

>> or learning a new environment
If you want to do this as a hobby that's ok. But no company uses that compiler any more.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Santa brought me a big and nice finger ¬¬ (nothing)

Naughty all year huh?:eek:

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

got a cell phone, now I just have to learn how to use the blasted thingamabob.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You should study this MSDN article. I think it includes some example too.

[edit]Just noticed the link is for VB .NET, not VB 6. This might give you a start. I'm sure there are many examples. [/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what version of gcc do you have? The program looks ok to me. Maybe you need to upgrade to Fedora 6 which will also upgrade your compiler.

>>undefined reference
that usually means you need to specify the c++ libraries on the command line.

gcc test.cpp lib<archive name here>.a -o test
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

bad link -- either fix the link or post the code. My guess is that you either used an old header file or no header file at all. should be <iostream>, not <iostream.h> (doesn't have a .h extension)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fscanf() will read just one word at a time, which will greatly simplify the solution to the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How about BoundsChecker

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My solution would be to write a public get function and use it in the loop instead of attempting to accessing the private member directly.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you did not code the class constructor or destructor.

Opra_record() {}
    Opra_record(const Opra_record&);
    ~Opra_record() {}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Opra_record* rec; // = new Opra_record;
you misquoted that. remove the star. Its the difference between static allocation and dynamic allocation. The object is instantiated, and the constructor is called.

Your operator>> function requires a reference to a statically allocated object and you were attempting to pass a pointer. Doesn't work.

>>I changed the line that you had changed. Same error.
you did not change it correctly. it still has the star which is causing the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

this compiles without error or warnings using my compiler which is not g++.

#include <fstream>
#include <vector>
using namespace std;

class Opra_record {
    friend std::ifstream& operator>>(std::ifstream&, Opra_record&);
private:
    std::vector<std::string> stringData;
    std::vector<long> numericData;
    std::string temp;
 
public:
    typedef std::vector<std::string>::size_type size_type;
    Opra_record() {}
    Opra_record(const Opra_record&);
    ~Opra_record() {}
    Opra_record(const std::vector<std::string>&);
    size_type size() const;
    std::string& operator[] (size_type i);
    const std::string& operator[] (size_type i) const;
 
};
 
std::ifstream& operator>>(std::ifstream& in, Opra_record& r)
{
	return in;
}
 
void parseFile(ifstream& in)
{
    string tmp;
    Opra_record rec;// = new Opra_record;
    while(!in.eof()) {
        in >> rec;                 ///***************here 
    }
}
 
int main(int argc, char** argv){
    if (argc < 2)
        return(EXIT_FAILURE);
    ifstream in(argv[1]);
    if(!in)
        return(EXIT_FAILURE);
    parseFile(in);
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you forget to include <fstream> ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Isn't this leaking memory (aside from the fact that no attempt is made to delete the lost memory)?

yes it is -- I hadn't noticed that error.:o

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

or this, which is almost identical to what ~S.O.S.~ posted. Like most things in programming there is always more than one way to do it. Unless you are instructed to do otherwise you can choose whichever method you want. One is not any better than the other unless you make the buffer too small to hold the result. In that case neither version will work correctly.

#include <iostream>
#include <ctime>
using namespace std ;
 
int main( )
{
    char buffer[BUFSIZ] = { '\0' } ;
    time_t now = time( &now ) ;
    struct tm* local_time = new tm( ) ;
    local_time = localtime( &now ) ;
    sprintf(buffer,"%02d/%02d/%04d",
          local_time->tm_mday,
          local_time->tm_mon+1,
          local_time->tm->year+1900); 
    cout << buffer ;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want to write a function that returns more than one value you have to pass parameters by reference or pointer to the function so that it can populate it with the needed information. Example in c++.

void BreakUp(int intNumb, int& first, int& second,int &third) {
 
 first = intNumb / 100;
 second = (intNumb - (intFirst * 100)) / 10;
 third = intNumb - ((intFirst * 100) + (intSecond * 10)); 
}

int main()
{
<snip>
      BreakUp(a, intFirst, intSecond, intThird);
<snip>
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>may you explain it plaese ?
If you look at a standard ascii chart you will see that the letter '0' has a decimal value of 48. So, to convert a binary value all you have to do is add 48 to it. For example, assume there was just one capital letter in the string, that makes dl = 1. add 48 to that gives you dl value of 49. Then look at the ascii chart and see that the decimal value of 49 is the letter '1'. Note that the letter '1' and the decimal value 1 are not the same thing.

>>f the user is allowed to enter a sentence with maximum 19 capital letters , How the display3 will be ?
don't you mean 9 capital characters? Display2 shows MSG3. There is no Display3 (or at least you did not write one).

display3

first we have to display number 1

like :
<snip>

I don't see any requirement for you to display two digits. There is not limit to the string length you can enter, only a limit of 9 capital letters. You can enter 255 characters if you want to.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well I think you are making things worse, not better. Here is one way to do what you want. I have not assembled or tested this.

;----
; ---- start of loop reading the keyboard
; ---- one character at a time
;----
mov bX,0 -- initialize capital character counter
loop_top:
MOV AH,1  ;READ A CHARACTDR
INT 21h
cmp al,0dh ; end of line?
je Display1 ; yes, then stop
; test for capital letters
cmp al,'A'
JL loop_end ; if char < 'A' then go
CMP al,'Z'
JG loop_end ; if char > 'Z' then go

INC bx  ; increment capital letter counter
cmp bx,9
JG Display2 ; too many capital letters

loop_end:
jmp loop_top


 
Display1:
LEA DX,MSG2  ;GET MSG1
MOV AH,9  ;DISPLAY STRING
INT 21H  ;DISPLAY MSG1

mov dl,bl ; print the number of characters
add dl,'0' ; make it readable
MOV AH,2  ;display the character that is in dl
INT 21H
jmp exit_program ; all done
 
Display2:
LEA DX,MSG3  ;GET MSG1
MOV AH,9  ;DISPLAY STRING
INT 21H  ;DISPLAY MSG1

exit_program:
MOV AH,4CH ; return control to DOS
INT 21H
 
MAIN ENDP
 END MAIN
END
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
JMP Count
CMP al,'Z'
JMP Count
LOOP TOP

The jumps are incorrect -- please see my previous post. jmp instruction is an unconditional jump meaning that the program will go regardless of any previous comparisons. you need to use the JL and JG jumps are in my example.

Also you failed to remove the LOOP. See my previous post for explaination why you can not use that in your program.

Out of curiosity, what other programming languages do you know? loops in assembly are very much the same in all other languages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
cmp al,'A'
CMP al,'Z'
JMP Count

you have to put a jump after every comparison -- see my previous code for example.

>>LOOP TOP
you can not use that construct in this program because you have to set cx to the number of times you want it to loop. use a jmp instead of loop.

>>MOV AH,1 ;READ sentenc
move that line down a bit so that it is inside the loop and befor the call to int 21. I think you have to reset ah every time.

>>mov bX,0
move that down a bit just before the beginning of the loop so that int 21 functions does not destroy its value. It may not, but you don't know for sure.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That loop needs to check for al = 13H ( <Enter> key) to stop the loop. As coded now the loop will never stop.

>> Mov bl,al
Why do that? just use al for tests

cmp bl,'A'
 
JGE Count
 
CMP bl,'Z'
JLE Count

I think you have the comparisons backwards. If the character < 'A' or > 'Z' then it is not a capital letter.

cmp al,'A'
 
JL Count
 
CMP al,'Z'
JG Count

>>My problem is on counting the number of capital letters .
You have to select a register to do the counting. cx is normally used for that purpose, but bx and dx will do as well. Just initialize it to zero before the loop and increment it after the checks

xor cx,cx ; clear the register
TOP:
 
INT 21h
 
cmp al,'A'
JL Count
CMP al,'Z'
JG Count
inc cx ; count number of capital letters

Count:
LOOP TOP
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
float calcMode(ifstream& inFile, int freq[], int size);

...
...
float calcMode(ofstream& report, int frequency[], int size)
{

Those are not the same functions. The parameter types must be identical in the prototype and the actual function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

repost your code and also attach the data file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
ifstream inFile;
ofstream report;
report.open("scores.txt");
if (!report)
{
	cerr <<"\aerror opening  output file\n";
	exit(102);
}
size= getNumbers(report,numbers,MAX_SIZE,NUM_RANGE);

<snip>

int getNumbers( ofstream&  report,int numbers[ ], int size ,int NUM_RANGE)
{
      ifstream inFile;
	inFile.open( "scores.txt" );

why do you open scores.txt for output in main then expect to read anything from that file in getNumbers()? When you open the file for output in main() all data in the file is lost. So getNumbers() will not really do anything.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

. Do you want me to run the loop within a loop or it is suppose to be a sepertate loop.

get the sum as you are doing now, but after the loop finishes, the average is just the sum divided by the number of items. No point in calling a function to get that simple calculation.


>> MOST IMPORTANTLY, i can't figure out that how can i get the average grades in letter

The average used in calculating the standard deviation is NOT a letter grade such as 'A', or 'B', but the numerical average, such as 3.5. The letter grade is not even mentioned in the requirements you posted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I.e for each of
the n values, you take the difference between that value and the
average, square that difference, and sum all n squares. Then divid that
sum by n-1 and take the square root of that quotient. This gives you
the standard deviation.

That is how the sd is calculated. It will be a lot easier for you if you just take the requirements one sentence at a time. Below are code snippets of what I think will work -- I didn't compile or test them. But hopefuly it will give you an idea of how to do this.

// get simple average of all scores
average = sum / SIZE;
...
...
// [b]inside a loop[/b], do first sentence. 
double diff = (scopre[i] - average) ;
sum_of_squares += (diff * diff);
///
// after the above loop finishes, do second sentence

n = sum_of_squares / SIZE;
standard_deviation = sqrt(n); // sqrt() is in math.h
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I am not familiar with functions and i tried to create it but i fails to run
please post the code so that we can help you. What compiler and operating system are you using?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
while(*(p+*p))

Does that really work :eek: doing pointer math using a character in the string. *p deferences the string, so if it happens to point to the letter 'Z', the result of the pointer math would be *(p + 'Z') or *(p+90) which might attempt to dereference the pointer way beyond the end of the string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to make your program a little more complex. Instead of one big spirntf() line you need to create a loop, for each row, search all rows from 0 to current row-1 to see if it is a duplicate, if not then use strcat() to copy its value into string1 array. Note that you will not use sprintf() at all.