Denniz 103 Posting Pro in Training

492

Denniz 103 Posting Pro in Training

Line 19: Replace << with semicolon ;
Line 22: "If" should not be capitalized too

Denniz 103 Posting Pro in Training

492

Denniz 103 Posting Pro in Training

Gonna learn about some press release stuffs today.

Denniz 103 Posting Pro in Training

Why not? My credit card is always inside my wallet. Is there any reasons not to carry it around?

Denniz 103 Posting Pro in Training

Hi welcome to Daniweb! What language do you used?

Denniz 103 Posting Pro in Training

Hi welcome to Daniweb!

Denniz 103 Posting Pro in Training

Hi welcome to Daniweb! I am a football fan too. :)

Denniz 103 Posting Pro in Training

Hi welcome to Daniweb! VB is rather simple, I used to debug VB codes even though I don't know the syntax.

Denniz 103 Posting Pro in Training

I suppose you are using Visual C++. From the little info that you give, you seem to be calling the function AfxMessageBox, but passing parameter that does not match its declaration.

We need to see the codes where you call this function, and the full error message (your error message says "convert parameter 1 from type 'char [30]", but did not mention to which type?).

Denniz 103 Posting Pro in Training

Take away all those semi-colons after the if and else-if statement:

if (score >= 85); 
        grade = 'A';
	 else if (score >= 75); 
        grade = 'B';
	 else if (score >= 65); 
        grade = 'C';
	 else if (score >= 55);
	    grade = 'D';
	 else 
	    grade = 'F';
Ancient Dragon commented: Good catch, I hadn't noticed that :) +36
Denniz 103 Posting Pro in Training

These two files are the compiler and linker. You probably have to restart your visual studio, or even reboot your pc, and try it again.

You can try to create a simple hello world application and compile, to see if this problem persist. If it persists, then the problem probably lies with the installation of your visual studio. You may need to reinstall it then.

Denniz 103 Posting Pro in Training

Where did you assign the value for variable num?

Denniz 103 Posting Pro in Training

You don't need an extra function. Just add one more case option inside the function do_next_op.

Denniz 103 Posting Pro in Training

Read the recruitment sections of the newspaper. Or register to some job seeking site.

I don't think this is the right place to look for job.

Denniz 103 Posting Pro in Training

Just ate some fried bee hoon and chicken wing for breakfast...

Denniz 103 Posting Pro in Training

How about teaching your girlfriend some programming?

Denniz 103 Posting Pro in Training

Hi Randy, welcome to the forum! Perhaps you should learn one language at a time so as not to confuse yourself over the syntax.

Denniz 103 Posting Pro in Training

Hi welcome to Daniweb. Don't worry, just enjoy your learning process!

Denniz 103 Posting Pro in Training

Welcome to Daniweb!

Denniz 103 Posting Pro in Training

Hi Prasad, welcome to Daniweb!

Denniz 103 Posting Pro in Training

Do you know the difference between declaring a function and calling a function?

To declare a function, you do this:

void instruction();
void divide_by_zero (char, float);
float do_next_op (char, float, float);

To call a function, you do this:

instruction();
divide_by_zero (op, num);
accum = do_next_op (input, num, accum);

Notice the difference. When declaring a function, like what you do at the beginning of your code, you specify the function name, the return type, and the type of parameter to pass to the function.

When calling a function, you just write the function name, and the ACTUAL variables which you want to pass into the function.

Also, remember the function declaration must MATCH the function definition.


Your last portion of codes have a few problems:

float  divide_by_zero (char op,  float num);
switch (op) 
{
       case '/';
       if (num == 0 )
       	{
				cerr << "Divide by zero" << endl;
			}
			else total /= num;
			break;
			return total;
        }

1. Take out the semicolon that follows the function. You need open and close braces to specify the scope of the function. Like this:

float  divide_by_zero (char op,  float num)
{
  // Your code here

  return total;
}

2. All your open and close braces within the function are in a mess. Go settle it.

3. Go look up the syntax for switch statement.

4. If I were you, I would not check for "/" in the divide_by_zero function because you …

Denniz 103 Posting Pro in Training

If there's no further issue, please mark the thread as solved. :)

Denniz 103 Posting Pro in Training

You should choose Win32 Dynamic Linked Library instead of MFC AppWizard (DLL).

After choosing that, select "A simple DLL project". Overwrite the original DllMain function that VC++ provides with this DllMain function that you have at the end of your codes:

bool APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
  DisableThreadLibraryCalls(hModule);
  Bypass();
  return true;
}
return true;
}
Denniz 103 Posting Pro in Training

There are some more problems with your codes:

1. You never initialized the variable "removed", yet you used it to keep track of the turns:

removed += turn; //Keep a running total of turns

This will lead to unpredictable behaviour.

2. Why use double for all the variables? Since you are dealing with discrete items like coins, you should use integer instead.

3. You should use while-loop for your validity checks. Using if-statement will only check once.

Denniz 103 Posting Pro in Training

There are a number of ways to get out of the loop. One way is to put the break statement when someone wins the game:

if (left < 1)
{
cout << " Player 1, You have one the game!" << endl; 
break;
}

Else, you can set a flag to true whenever someone wins the game, and then put the check for the flag as one of the condition of the while-loop.

Denniz 103 Posting Pro in Training

I just realize from the other similar thread that this is the last question on your assignment. So before this question, you would have to implement the power function and squareroot function. Why jump straight to this one? You need to implement those two functions and then call them inside this hypotenuse function.

Denniz 103 Posting Pro in Training

Hi welcome to Daniweb!

Denniz 103 Posting Pro in Training

Just have some japanese food for lunch. :)

Denniz 103 Posting Pro in Training

Hi Nishant, welcome to Daniweb!

Denniz 103 Posting Pro in Training

Hi welcome to the forum! Please post your questions under Tech Talk->Microsoft Windows or the relevant sub sections under it.

jbennet commented: thanks +31
Denniz 103 Posting Pro in Training

Hi arun, look forward to your participation!

Denniz 103 Posting Pro in Training

Hi Jean, welcome to Daniweb!

Denniz 103 Posting Pro in Training

You should use the function sqrt() to find the square root of a variable.

For example:
c = sqrt(x);

You will need to include the header file <math.h> to use this function though.

Denniz 103 Posting Pro in Training

Take away this line:

return displayGrade;

As for the loop, it will keep on prompting you for the next score, until you enter -1 then it will come out of the loop.

Denniz 103 Posting Pro in Training

The parentheses are wrong. Look closely:

c=(((a/c)+c)/2)+((b/c)+c)/2)));

Also, are you sure that's the correct formula for calculating the hypotenuse? Why is variable "c" used in the formula for computing "c" ? Even if the formula is right, the variable "c" isn't initialized at all. And I am quite sure the formula itself is wrong.

Denniz 103 Posting Pro in Training

Try writing out the function and post it here. The driver file is supposed to call the function, pass parameters to it, and gets return value (if any) back. It is used for the purpose of testing whether the functions work correctly.

Denniz 103 Posting Pro in Training

I don't know how to write the divide by zero function, and I don't know why the void function to display the instruction does not run too,

Anything divide by zero will become infinity. So you need to cater for the case whereby the operator is "/" and the operand num is 0. If such case is met, instead of performing the computation, maybe you should displaying some error message.

Denniz 103 Posting Pro in Training

Have you tried to compile?

Your header file needs the statement "#endif" at the end. The inclusion detection system works in this way:

#ifndef FUNCTION_H
#define FUNCTION_H

// Put all your declaration here

#endif

The reason for doing this is to prevent the compiler from parsing the same header file more than once (thus preventing duplicated declaration) when compiling a source file. The #endif statement tells the preprocessor the end of the scope for this inclusion detection (similar to the closing brace } ).

Your driver function simply doesn't work.

Denniz 103 Posting Pro in Training

Look at your line 60 and line 66. This is not the way you decrement the value.

You should do this:

STAMINA = STAMINA - 2;

or this:

STAMINA -= 2;
Denniz 103 Posting Pro in Training

I've already read that, and it tells me just the things I dont really need to know right now. It doesn't give me a good example of displaying text, and it doesn't say anything about if statements.

I need to be able to say:

if (money > 0) then say 'hey. you have money.'
if (money =< 0) then money = money +5 and say 'hey, I just gave you five bucks.'

thanks so much. this would really help.

I just browse through the site that Aia provides. It DID tell you the things that you need to know right now, that is, to understand how a windows application works.

You need to understand that a windows application works very differently from a console application. You need to know what is a message loop, what is a window, what are controls, what are event handlers, what are windows handle, etc. And those are just the basics.

Denniz 103 Posting Pro in Training

I've already read that, and it tells me just the things I dont really need to know right now. It doesn't give me a good example of displaying text, and it doesn't say anything about if statements.

I need to be able to say:

if (money > 0) then say 'hey. you have money.'
if (money =< 0) then money = money +5 and say 'hey, I just gave you five bucks.'

thanks so much. this would really help.

if-statements still works the same way as console-based application.

What you need to know is how a windows application works, not how if-statement works. Windows application basically has a loop that constantly process messages. Every user actions, such as a mouse-click, a keyboard typing, a mouse movement, will generate different messages that are processed by this loop. Programmers would override the function that process these messages. This is the basis of how Win32 application works.

However, if you use Visual C++ & MFC, you can simplify these procedures because MFC provides classes and framework that wraps around the Win32 API. If you want to learn how to create windows application using Visual C++ and MFC, I suggest you grab a textbook on that because there are simply too many things to explain in a forum.

Denniz 103 Posting Pro in Training

This is where the problem is:

for(int i=0; i<MAX; i--)
		cout<<Input_String<<endl;

You initialize variable "i" to zero, decrement it in every step, until it is smaller than MAX (which is 100). So, "i" would go from 0 to -1, -2, -3, -4 until to some large negative number like -2^16. You should initialize "i" to the end of the string, then decrement it to zero.

Also, you are trying to print out the entire string, instead of printing character by character. You should do something like this:

cout<<Input_String[i];
Denniz 103 Posting Pro in Training

I saw a very similar post with a very similar question here just now. Classmates? :P

Anyway, the rules here is that you need to try out yourself, show us what you have done, what problems you encountered, and then we will help you to solve the problems.

Don't believe in the myth that solutions would magically appear if you post some homework on Daniweb.

Denniz 103 Posting Pro in Training

I can't get access to a compiler atm but I will tell you no it don't work.

Denniz 103 Posting Pro in Training

I did not go through the entire post, but I notice your myfunction.h has something wrong. The first few lines of declaration did not state the return type and the required parameters. Also, the inclusion detection should be at the very beginning of the file.

Denniz 103 Posting Pro in Training

It would be good if you can attend some kind of open house or course preview talk at those university to find out more about the prerequisite. Most Comp Sci courses do not need prior programming knowledge, but as you go along there will be some application of mathematics such as matrix, algebra, vectors, etc.

Comp Science courses in universities do not teach only programming. There would be a fair amount of theoretical subjects, and most probably do not teach you any web design. So, do attend the course preview talks if any to understand more about the courses.

Denniz 103 Posting Pro in Training

Am I the only one from Singapore?

Denniz 103 Posting Pro in Training

Welcome to Daniweb!

Denniz 103 Posting Pro in Training

Rice with some curry chicken and vege.