C++ :: Fees Showing Up Wrong On Program

Feb 19, 2014

I'm writing a program that shows check fees for different amounts of checks. My other fees are showing up right but the .10 cents is not. It's showing up as .08 cents per check when I run the program.

Oh yeah the + 10 is for a $10 fee

Code:
else if (checks < 20 || checks >= 0) {
fee = .10 * checks + 10;
cout<< "Bank service charge for the month is $ " << setprecision(4) << endl;
}

View 3 Replies


ADVERTISEMENT

C :: If Put WRONG Input For INTEGER / Program Will Restart

Feb 15, 2015

I have a question about my program.. I would like to make a program that if you put "ABC" on INT, the program will restart again... below are my coding...but it not works..if i put ABC on INT, the "Invalid Mark.. please re-insert mark :" will repeat, repeat and repeat infinitely...

Code:

#include <stdio.h>
void calcul() {int mark;
char * grade;
if (!(scanf("%d",&mark))){printf("
}

[code]....

View 7 Replies View Related

Visual C++ :: Payroll Program Is Showing Zero In Output Section

Nov 25, 2013

The program is showing zero in output section ....

Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

The output:

Code:
First Last Employee Hours Rate Regular Overtime Gross
Name Name Number Worked of Pay Pay Pay Pay
==============================================================
Jane Adams A1234 40.00 10.00 0.00 0.00 0.00
Mary Lincoln L8765 50.00 10.00 0.00 0.00 0.00
Martha Washington W7654 25.50 10.85 0.00 0.00 0.00
John Adams A9876 52.00 15.75 0.00 0.00 0.00
George Washington W1235 45.00 25.00 0.00 0.00 0.00
Abraham Lincoln L9087 40.25 55.00 0.00 0.00 0.00
William Tell T9876 30.00 9.75 0.00 0.00 0.00

View 12 Replies View Related

C++ :: Program Compiles Successfully But Calculations Give Wrong Answer

Feb 11, 2013

I'm using MSVC++ and it builds sucessfully but somewhere something is obviously messed it. Once i try to debug it just shows weird numbers.

int k=0; //could this be the problem??? since 0 would be over writing any given value. but if i leave int k; it showsa warning and MSVC would count that as an error

#include "stdafx.h" //Header file section
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//structure declaration
struct menuitemtype

[Code] ......

View 14 Replies View Related

C++ :: SDL Font Not Showing

Jan 19, 2013

SLD_ttf lib and I have been following the Lazy Foo' tuts on it but the text is not appearing. I have found out that it is not loading the font as I have added in the code saying if it has failed.

Code:

font = TTF_OpenFont( "lazy.ttf", 28 );
if( font == NULL )
{
return false;
}

i have saved this font in the project (project name/project name/lazy.ttf).

View 19 Replies View Related

C++ :: Image Not Showing On Top

Jul 1, 2013

I am trying to display images on top of my Background image gui, so like buttons an stuff but the problem is that there not showing ontop. I can only get one of them to show

// includes
#include <windows.h>
#include <stdio.h>
#include "res.h"

// defines
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002

[Code] ....

View 1 Replies View Related

C++ :: Output Is Showing Address Instead Of Value

Dec 7, 2013

I've run across this issue before, but for the like of me, I can't figure out what keeps causing it. The problem compiles and runs as expected; however in the salaried object (Employee #1 in main.cpp) the console displays the number of vacation days as -858993460 instead of the value entered.

The parent Employee class is abstract with calculatePay() and displayEmployee() being pure virtualls and with a Benefits, Salaried, and Hourly class derived from it.

The Salaried displayEmployee() and the portion of the Main.cpp that contains the salaried object follows. What causing this?

Salaried displayEmployee()
Code:
void Salaried::displayEmployee()
{
cout << endl;
cout << "Employee Information" << endl;
cout << "----------------------------------" << endl;
cout << "Employee Name: " << setw(7) << FirstName << " " << LastName << endl;
cout << "Gender: " << setw(12) << Gender << endl;

[Code] .....

View 2 Replies View Related

C :: Float Showing Nothing In Printf

Oct 6, 2014

I just checking but confused with float. in that code same size int, and same type double are working but float showing nothing in printf..why?? i'm using GCC compiler int 32bit win7 os

Code:
#‎include <stdio.h>
int main() {
char arr[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
printf("Size of char=%c
", ((char *) (&arr[0]))[1]);

[Code] ....

View 14 Replies View Related

C :: Calculating And Showing RPM On Display

Feb 19, 2014

As part of a project i want to display the speed of a small wheel on a 7 segment display. I am using a hall effect sensor to pick up the pulses of the rotation. I am not sure how to write a programe on C to calculate the RPM from this....

View 4 Replies View Related

C++ :: Calculations Are Done Correctly But Showing Zero

Nov 26, 2013

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

View 1 Replies View Related

C/C++ :: Showing The First Digit Of Zip Code?

Nov 21, 2014

My question is why my on my code there is 10 zip code and i want to show the first digit, the problem is the first digit does not match the zip code for example the zip code is 45805 it should be '5' however, my code shows other number!

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

[Code].....

View 4 Replies View Related

C++ :: CPP File Not Showing Code

Nov 19, 2013

i have been making code of a chessgame and now sddenly computer freezed and now there's not code in .cpp file! Although my .cpp file shows size of 16kb but when i open it . there's nothing except bank file

View 1 Replies View Related

C++ :: Tic Tac Toe - Board Is Not Showing Numbers

Feb 7, 2014

I'm programming tic tac toe but the board is not showing numbers, and it is simply stating the winner without any input: (the win conditions are not complete, but it shouldn't matter).

#include <iostream>
#include<string>
using namespace std;
//Write a two-player tic-tac-toe game; use enums when possible to represent the values of the board

char ticBoard[3][3];
char board[10];
void showBoard();
bool moveIsValid(int m);
int whoWon(); // 0 tied, 1 p1, 2 p.2

[Code] ....

View 6 Replies View Related

C# :: Variable Showing As Not Instanced

Oct 19, 2014

I'm receiving an error that an array has not been initialized but I'm not quite sure why. Also, I realize a list may be better in this scenario but I would still like to know what I'm doing wrong.

Warning in the IDE

Warning3Field 'Routines.SvrMain.Servers' is never assigned to, and will always have its default value nullD:Google DriveCodingC# ProjectsNONameWindowsFormsApplication1WindowsFormsApplication1Routines.cs26638WindowsFormsApplication1

Error that pops on line
Servers[Index].Address = Parser.ReturnAddress(); //returns an IPAddress

Object reference not set to an instance error

ServerDetails Class
public class ServerDetails {
public IPAddress Address; { get; set; }
public int Port { get; set; }
}

[Code] ....

View 12 Replies View Related

C/C++ :: Why Invalid Letter Not Showing

Feb 29, 2012

I wanna know why the program doesnt show "Invalid Letter Entered" when i enter any letter other than A S D or M

//Processing the data
    if (letter== 'A'||'S'||'M'||'D')// checking Add, subtract, multiply or divide {
        if (letter== 'A')//Adding the integers
            cout<<"Adding two integers = "<<first + second<<endl;
        else if (letter== 'S')//Subtracting the integers  {

[code]......

View 1 Replies View Related

C++ :: Variable Assigned Wrong Value?

Nov 15, 2012

Consider the following:

Code:
float foo( float const *bar )
)
{
float temp;
temp = *bar;
...
}

Something I am noticing is that temp right after the assignment to *bar, is not the same value as *bar. This is for a project at work and the code runs on an embedded board with an ARM processor. I've copied the function into a standalone program for both Visual Studio and Code::Blocks and it works correctly there.

View 12 Replies View Related

C++ :: Input Showing As Default Values?

Nov 30, 2013

Same solution that I was having compiler errors on yesterday. We're working with inheritance and the program is supposed to be to create and display information for default Employee objects, Hourly Employee objects and Salaried Employee objects. Everything compiles as is, but I'm running into two issues that I can't figure out.

1) In both the hourly and salaried objects, the wage, hours, and management level attributes all displaying their default values. I'm almost positive that this has something to do with the str to int and str to double conversions that I'm using (currently have atoi and atof in the file, but I've also tried stringstream, but still had to same problem). Any thoughts as to what I'm missing?

2) the assignment calls for the Benefit benefit member in Employee.h to be protected. However this makes the member unaccessible when I try to use it in the EmployeeMain.cpp in order to set the input for the Benefit class members. I had to make the Benefit benefit member public again to get it to compile. How would I set the input for the Benefit class members while the Benefit benefit member is protected?

Solution files follow:

EmployeeMain.cpp
Code:
#include "Hourly.h"
#include "Salaried.h"
void DisplayApplicationInformation();
void DisplayDivider(string);
string GetInput(string);

[Code]....

View 3 Replies View Related

C :: Guess 4 Int Array With How Many Are In Right And Wrong Positions

Feb 11, 2013

For an assignment I have to create a random array of four integers, and then I have to allow someone to input up to ten guesses to guess the array in the correct order. I also need to be able to display whatever was generated by inputting -1. Finally, after every guess I have to tell the inputter how many of the guessed integers are correct and in the correct position, as well as how many integers are correct but not in the correct position.

So far I've been able to get the random array to generate properly, but inputting negative one has no effect, although if I input it four times in a row I get to my 'lose' condition. Also, it only seems to allow the user to input 4 guesses and not 10 before going straight to the 'lose' condition. I need to get these issues sorted out before I can move on to showing how many guesses are right etc....

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time (NULL));

[Code] ....

View 3 Replies View Related

C :: Multi Character Is Showing Error

Mar 26, 2014

When i am entering single character instead of 'miz' then it is working great. But when i am using multi character like 'miz' it is showing error output. i did this program with c++ it is working but not working in c.When i am running this program it is showing {warning] multi character constant.

Code:

#include<stdio.h>
#include<string.h>
main()
{
char a;
printf("Please Enter your First Name: ");
scanf("%s",&a);

[Code]....

View 1 Replies View Related

C# :: Des Encryption Produces Wrong Output

Feb 14, 2012

I have the following function:

Code:
public static void Des(byte[] key, byte[] inBuf, byte[] outBuf) {
if (key.Length != 8 || inBuf.Length != 8 || outBuf.Length != 8) {
throw new Exception("Des: Buffer or key length incorrect.");
}

DESCryptoServiceProvider des = new DESCryptoServiceProvider();

[Code] ....

I do not get the expected output of

Code: { 0x88, 0xBF, 0x0D, 0xB6, 0xD7, 0x0D, 0xEE, 0x56 }

instead I get

Code: { 0xC6, 0x61, 0x8D, 0x63, 0x0B, 0x39, 0x31, 0xB0 } am I doing something wrong?

I've even tried reversing the byte order of the test data, and I don't get the right result. I've tested the same data using C++ with CryptoPP on Linux, and I get the expected result, but I'm porting this code to run on .Net, and this is my main stoppage in the process at the moment.

View 5 Replies View Related

C :: Sensor Values Reading Wrong

May 24, 2014

My whole code is working but when the results are sent to my phone only the temperature value is reading correct the light value is all jungled up and moisture and pressure values are reading as 0.

Code:

#include "taskFlyport.h"
#include "grovelib.h"
#include "barometer.h"
#include <string.h>
extern BOOL incomingSMS;
extern int incomingIndexSMS;
extern BYTE incomingMemSMS;

[Code]...

View 4 Replies View Related

C++ :: Sensor Values Reading Wrong

May 26, 2014

I am only receiving the correct temperature value. The other 3 values are reading wrong. My format string isent matching the variable list. What I need to do.

float data_bar = 0.0;
float data = 0.0;
float anVal = 0.0;
float moistureVal = 0.0;
while(1) {

// Get the new value using the get() function

[Code] ....

View 3 Replies View Related

C++ ::  SendInput - Cursor Position Wrong

May 12, 2013

I recently wanted to create a (yet) simple program that simulates a mouse movement.So far I managed to make the program work. It does move the mouse, click when expected but the problem is the location it does click at.Here's my code:

#include <Windows.h>
#include <stdio.h>
int leftclick (DWORD x, DWORD y);
int main(){

[code]......

The problem now is: I want the program (for testing purposes) to click at (1920, 1080) and (100, 100) afterwards. Now it does click within a specific range. When I use GetCursorPos to retreive the cursors position it differs quite a bit from where I expected the click to be.

a second question I have is: When I declare the following flag (in the code above) the program does use relative coordinates even though it shouldn't.

input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;

Where as it works out well when I add a MOUSEEVENTF_MOVE to it.I couldn't find any solution to this in Microsoft MSDN or any other website.

View 2 Replies View Related

C++ :: Check Wrong Input Data

Jan 20, 2013

i'm making a for loop for a mini game which required the user to enter the input number.Let say if the user accidently entered a character instead of integer the whole program will go haywire so is there anyway to check for the error and prompt the user to input the data again?Here is the simple program...

for(row=0;row<4;row++)
{
printf("Enter Row%d:",row);
for(col=0;col<4;col++)
{
scanf("%d",&num[row][col]);
}

View 1 Replies View Related

C++ :: WAV File Reading Wrong Data

Jan 19, 2015

I have been experimenting with a program that loads WAV file and tries to read 1s and 0s from audio file (binary coded information). So far I got working code, but the problem is that I'm not getting correct data. I do get somewhat similar data. The problem is that I get data that amplifies low amplitudes, so instead some noise and binary data I get lots of noise and hard to recognize binary data. My code is this

#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
// An unsigned char can store 1 Bytes (8bits) of data (0-255)

[Code] .....

This is wav file in binary viewer (after header)

0030 0032
00300035003200320035003A0048004A
004C0049004A00510049004300360038

and translated to decimal

48 50
4853505053587274
7673748173675456

and this is output from "wavosaur" program (and this one is correct)

0.001465
0.001526
0.001465
0.001617
0.001526
0.001526
0.001617
0.001770
0.002197
0.002258
0.002319
0.002228
0.002258
0.002472
0.002228
0.002045
0.001648
0.001709

You can see it's not the same. I do get the same data like I do from binary viewer, but I don't understand how they are translated to amplitude value. ? Where is the catch?

So this is not really question about c++, but about wav file structure and reading data.

View 2 Replies View Related

C++ :: Cin Input Validation Returns Wrong

Jul 11, 2014

I have this function that is supposed to take a float as a parameter and then call the getLine() method to accept the users input. The function basically just checks to see if what the user input was of the same data type, if it is it returns the input value, if not then it keeps looping through taking new input until its correct. The problem is no matter what number you put in the output always returns as 140734799803512.

float InputValidation(){
float num;
string strInput;
while (true){
getline(cin, strInput);

[Code] ....

You also need to include <string> and <sstream>.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved