Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Help declaring floats!

Author
Message
NewProgrammer 10
12
Years of Service
User Offline
Joined: 27th Sep 2011
Location:
Posted: 28th Sep 2011 00:30
Hellow Im new to programming and we were given a simple assignment in class which was to construct source code that calculates the total number of differnt coins in a jar. There a 3 quarters, 5 nickels, 12 pennies, and 0 dimes. I am completely stuck but this is what I have so far. We are using DarkGDK in Microsoft Visual Studio 2008.

//include directive
#include "DarkGDK.h"

//DarkGDK function
void DarkGDK(){

int Quarters, Nickels, Pennies, Dimes, Total;

Quarters = .25;

dbPrint("How many Quarters?:");

Quarters = atoi(dbInput());

Total = Quarters * 3;

dbPrint("The Total is:");

dbPrint(dbStr(Total));



//waint for the user to press a key
dbWaitKey();
}

Can anyone help me out?
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 28th Sep 2011 01:55 Edited at: 28th Sep 2011 01:57
Quote: "Quarters = .25;"

You declared the varible "Quarters" as an int, for it to have a decimal in it it must be declared as a float.

Your code should look like this:
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 28th Sep 2011 22:08
It's also good practice to always put an "f" after your float values to keep the floating point precision:



Back then when I started with DarkGDK and C++ I wasn't aware of that and it caused some trouble...

Login to post a reply

Server time is: 2024-05-04 07:38:42
Your offset time is: 2024-05-04 07:38:42