spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Unexpected output in my simple class function. Why?


Please try this:

int getPay() {
    if (hoursWorked <= 35) 
        return hoursWorked * hourlyPayRate;
    else if (hoursWorked > 35)
        // Hourly rate for the first 35 hours and
1.5 time for 
        // the remaining = (hours -35)
        return (35 * hourlyPayRate ) +
((hoursWorked-35) * (hourlyPayRate * 1.5)); 
}

Categories : C++

Related to : Unexpected output in my simple class function. Why?
Unexpected Error while Executing Simple grep Script
Now that I understand your requirement better (my fault), here's a more fleshed out solution. prompt$ cat simpleGrepScript.sh #!/bin/bash if ${testMode:-true} ; then echo "processing file $1 into outfile ${1%/*}/../overallenergy.out" 1>&2 else [[ -f "$1" ]] && grep 'E-SUM-OVERALL' "$1" > ${1%/*}/../overallenergy.out || echo "no file "$1" found" 1>&2 fi Run prompt

Categories : Bash
Unexpected characters in console output
According to C++ Reference, you are right. As pointed out in the comments, for the string implementation you use, the arguments are switched. For the second example, you print the sign (111-1)/2 = 55 = '7' for ' ' = 32 times. Swap the arguments to string(' ',(111 - s.length()) / 2) and it should work better.

Categories : C++
MySQL joining tables gives unexpected output
why don't you get rid of the Left Join? This makes it easier to read. SELECT table_A.*, table_B.*, table_C.*, table_D.* FROM table_A INNER JOIN table_B ON table_A.my_field = table_B.my_field LEFT JOIN table_C ON table_B.my_field = table_C.my_field and table_B.complete ='1' LEFT JOIN table_D ON table_C.my_field = table_D.my_field

Categories : Mysql
Unexpected output in if & switch statements in C code
main doesn't accept the input from the command line as direct arguments, you are getting the argument count in there which is 1 if there are no arguments, and 2 if there is one argument, which causes the strange behavior. main should be defined as int main( int argc, char *argv[] ) or something similar. To get the input, you need to first check if it exists by testing argc (the argument count, pl

Categories : C
Unexpected Output for K&R Exercise 1-18 (The C Programming Language)
Look closely at the line you mention: while ((better_line_length(s, MAXLINE)) > 0) { If the function better_line_length() returns 0 the condition is false and the loop ends. That's why it's giving up at the first blank line. You should think about returning something different when you've really reached the end or just a blank line. You might (for example) return -1 when you've reached the

Categories : C
Recently Add
C++: error C2143: syntax error : missing ';' before '<'
Converting 2s compliment to a decimal. Output is double
how do you compare a string to a vector value?
Converting a long double to double with upward (or downward) rounding
C++: operator<< overloading in the nested classes
Unclear behavior with csv processing using getline
C++ Visual Studio Error: IntelliSense: expected a statement
Game of Nim - showing the remaining numbers and letting a player pick their name?
malloc 1D array in struct
How to create an array of smart pointers?
c++ swapping unique_ptr's
Functions as arguments
Any Fast & Efficient way to generate a 3D Grid?
Is string[] not a type?
C++ typeid(x).name() returns ph
Counting / Printing Path - From (1,1) to (m, n)
C++ input function that calls itself
Error: array must be initialized with a brace-enclosed initializer
SDL_ConvertSurface() causes break
C++ std deviation function?
libcURL Progress Function not being called
What is QList's maximum size?
Run batch with C++
Read a file and write its contents to another C++
extract from stringstream into 2D vector
How to stop Scons adding lib infront of a shared library
Blocking vs non-blocking mode in TCP sockets using C++
SDL2 toggle SDL_WINDOW_RESIZABLE state for fake fullscreen
How can I assign value to specific vector's index?
Operator Overloading with Constant Iterators
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.