|
G'Day I'am having a problem with a program that I'm working on for class. I do not expect to be given the solution. If someone could just steer me in the right direction.
An employee's gross wage is computed at the regular pay rate for the first 40 hours and 1.5 times the regular rate for each hour over 40.Thus, an employee who worked 50 hours at $5 per hour would have a
gross pay of $275.
For this part of the program I used an if/else statement:
if (hoursWorked <= 40)
{
grossPay = (hoursWorked * payRate);
}
else if (hoursWorked > 40)
{
grossPay = (hoursWorked * payRate) * 1.5;
}
This code compiles but does not give me the correct output. Any suggestions would be appreciated.
Thank - you,
billy73
|
|
|
|
|
you need to write like this,
if (hoursWorked <= 40)
{
grossPay = (hoursWorked * payRate);
}
else if (hoursWorked > 40)
{
int nHoursWithextraWage=hoursWorked-40;
grossPay = ( 40* payRate) + nHoursWithextraWage * payRate * 1.5;
}
I suggest following code will do,
int nHoursWithextraWage=hoursWorked-40;
nHoursWithextraWage= (nHoursWithextraWage < 0 ) ? 0 : nHoursWithextraWage;
grossPay = ( 40* payRate) + nHoursWithextraWage * payRate * 1.5;
|
|
|
|
|
If hours worked is neither less than or equal to 40 then it must be greater than 40 so the statement
else if (hoursWorked > 40)
is redundant. Just "else" will do
|
|
|
|
|
Wow. A one vote.
So whoever voted a one... so are you suggesting you program like this...?
if (true) {
} else if (false) {
}
how silly are we getting here. Sheesh!
|
|
|
|
|
billy73 wrote: grossPay = (hoursWorked * payRate) * 1.5;
Your problem is here. Do you really mean to pay 1.5x salary for every hour worked?
|
|
|
|
|
Hello guys.
I recently purchased a mouse for my laptop (MS notebook wireless optical 4000) it has a freat little feature, the mouse has a zoom button on the side of it, when its clicked a transparent window appears around the mouse pointer, and everything inside the window is magnified to the users preference. If you hold down the button, it gives you the ability to increase the zoom windows size and magnification via moving the mouse and the scroll wheel.
I also have a Intel Mac Mini dual Boot connected to my 32" HDTV, with this I use an Ione 2.4ghz wireless keyboard which has a little joystick to use as a mouse. The setup works great as a HTPC but when I do general windows tasks like browsing etc sometimes viewing can be alittle small from the couch potato position I sit at.
I recently connected my laptop to the screen and tried the MS mouse zoom from the same distance and it was a joy to use on the 32", however it wasnt really practical in the long run having my loptop connected up.
So im thinking what if I could take the features of ms zoom and create a small application to work with my wireless keyboard?
I know there are other 3rd party appz on the market, but none of them act quite like ms is one.
I have not been into my programming in a while, but I have just purchased VS2005 and will attempt the project in VC++ as its the only language I really know and I have the entire v6 reference Set gathering dust so I might aswell get some use out of it
Have any of you used a microsoft mouse with zoom onboard?
Im looking for tips on how to go about the project, Im very rusty and dont want to start off going down a dead end
|
|
|
|
|
wow thanks for all your help
|
|
|
|
|
hi, please comment if anyone knows or has encountered the following problems in VC++. ( i seriously doubt it though)
1. I have built an app with UNICODE enabled, and it has a treectrl. Strangely, when i set the text of items using any of the standard ways [ example text: (My group)]
the display shows the text as [((My group], that is, the bracket comes back in first place. This behaviour happens with almost all non-alphanumeric characters.
ALSO THIS HAPPENS ONLY on systems which have additional regional languages support installed from the control panel (Supplemental language support)
if you edit the item, or gettext,the text returns correctly. Build the MBCS version
or uninstall additional languages support, the problem goes away. I thought of reporting BUG to Microsoft in TreeCtrl, but before being called a stupid by MS people ...
2. When i call HttpSendRequest() using MBCS version, everything is fine, but building teh unicode application makes the POST data NULL. the data is passed correctly to the function, but on the server i get nothing in POST or GET or REQUEST. Serious help needed as i think i am missing some important clue here.
Thanks in advance.
|
|
|
|
|
Hello everyone!
(Note: I first posted this question here)
But I'll repost it, hopefully more clearly...
So let's say I have an error-free Player class... It's located on the files Player.h and Player.cpp . But there's a problem, the files don't include correctly... I've tried putting the class along with another class in Game.h/cpp , and that compiled, but not otherwise... Here's the code at the top of my files:
[Main.cpp]<br />
#include "Includes.h"<br />
<br />
[Includes.h]<br />
#pragma once<br />
<br />
#include <iostream><br />
#include <string><br />
#include <stdlib.h><br />
#include <time.h><br />
#include <vector><br />
using namespace std;<br />
<br />
#include "SDL.h"<br />
#include "SDL_image.h"<br />
<br />
#include "Defines.h"<br />
#include "Structures.h"<br />
#include "HelperFuncs.h"<br />
#include "Vehicle.h"<br />
#include "Player.h"<br />
#include "Game.h"<br />
<br />
[Game.h]<br />
#pragma once<br />
<br />
#include "Includes.h"<br />
<br />
[Game.cpp]<br />
#include "Game.h"<br />
<br />
[Player.h]<br />
#pragma once<br />
<br />
#include "Includes.h"<br />
<br />
[Player.cpp]<br />
#include "Player.h"
I tried everything on the previous thread, nothing worked... The error in VC++ 2005 is:
1>c:\incoming\war game\Game.h(10) : error C2146: syntax error : missing ';' before identifier 'mainPlayer'<br />
1>c:\incoming\war game\Game.h(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />
1>c:\incoming\war game\Game.h(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(Note: The 10th line doesn't matter, as I said the thing works if I merge Game and Player...)
If you can help me, I'll give you a cookie! Thanks!
PS: At first, I thought it was a problem with SDL not being compatible with VC++ 2005 because SDL download page says VC 5/6/7, not 8, but it doesn't compile under Code::Blocks (MinGW) either, it gives a similar error...
Windows Calculator told me I will die at 28.
|
|
|
|
|
I assume that mainPlayer is an instance of player ? You're not using precompiled headers ? I'd put all these includes in the stdafx, if you were using them.
Does it have to be an instance of Player ? Could it be a pointer ? class Player; at the top of game.h, and the include of player.h in the CPP would then work fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
In game.h get rid of
class Player;
because you are not using Player as a pointer and you
#include "Player.h"
in the next line.
John
|
|
|
|
|
Choose[^] any kind you want! Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
I'm a bit slow to reply today, I am sick. Has your problem been solved ? I thought so, from reading the replies, but if not, then yell.
Lord Kixdemp wrote: PS: Christian Graus, do you live here at CP?
Pretty close.
One other possible problem I thought of, does Player have a default constructor ( one that takes no arguments and is public ) ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
From that description, you need to clean up your include situation. For starters, your "includes.h" (analagous to stdafx.h in wizard-generated code) should not be included in other header files, only cpp files. The way it is now, if you're not using precompiled headers, you're seeing much longer compile times than necessary.
|
|
|
|
|
|
Each compiler has predefined symbols specific to it, so you can have conditionally-compiled code for different compilers. For example, VC has _MSC_VER which also tells you the compiler version.
|
|
|
|
|
|
Hi,
I am curious abt shortcuts to copying data from two buffers into one.
let's say I have an integer and a buffer of LPVOID type. Now i want to copy these two, int first and then all contents of LPVOId buffer( size known ) into the buffer supplied by the user(LPVOID type). memcpy or memmove will do only wholesale copy, no way to specify from what byte to start. is there any way other then byte by byte copy??
how do u do this kinda thing anyways?
any pointers will help, thnx
will something like this work
mydata is allocated and is of LPVOID type
myDataSize is UINT and have correct size( hopefully ) of myData
void copy( LPVOID buff, size )
{
memmove_s( buffer, size, (LPVOID)&someint, sizeof(int) );
buff += sizeof( int );
memmove_s( buffer, ( size - sizeof( int ) ), myData, myDataSize );
//return the input pointer to original value
buff -= sizeof( int );
}
//this could be totally laughable thing, but am jsut new to this kinda thing
//please excuse me if this code seems ridiculous
thnx for help.
|
|
|
|
|
yupp it was ridiculous. VOID does not have size so the compiler does not allow pointer aithemetic on it.
Any suggestions please!!!!
|
|
|
|
|
venadder wrote: //return the input pointer to original value
buff -= sizeof( int );
You're not returning anything. A pointer is not a reference. A pointer could be used as a reference, in which case you'd need a double pointer to modify buff so the calling function can see a change. Anyway what you are attempting to do is pointless as you are trying to preseve the original value, but the original value passed in by the calling function can't be changed in your function, you are only operating on a stack copy of the pointer value.
memcpy(buffer, &someint, sizeof(int));
memcpy(((LPBYTE) buffer) + sizeof(int), myData, myDataSize);
|
|
|
|
|
the problem is here
CTyptedPtrList m_ElementList;
instead use this
CTypedPtrList<CObList, CMyObject*> m_ElementList;
you are missing its parameters
Tanvon
the brain behind ...
|
|
|
|
|
code:
// Windows Programming Tutorial Series
#include "stdafx.h"
#include <windows.h>
int WINAPI
WinMain(HINSTANCE hInst,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MessageBox (NULL, "Hello World! This is my first WIN32 program",
"Lesson 1", MB_OK);
return 0;
}
2 errors:
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/a.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
a.exe - 2 error(s), 0 warning(s)
Who can make some suggestions please?
I guess it may be I did not include the lib well.
|
|
|
|
|
The linker thinks this is a console program whose entry point is the main function. You need to tell it that it is a windows program. In the compiler options, preprocess definitions section you will probably see a macro "_CONSOLE" defined. You need to remove that and add in the macro _WINDOWS there.
|
|
|
|
|
when I include this C++ source file into a "Win32 Application" project, it works;
when include it into a "Win32 Console Application" project, it fails;
my question is how to change the settings of the latter to make it work, without creating a new project of Wind32 Application.
I tried include the macro _WINDOWS in the setting->c/c++->preprocess definitions , but it did not work.
|
|
|
|