C++ :: Calculating Gross Pay - Arrays

Dec 4, 2013

I am just learning arrays, I modified my program to use arrays but now it wont calculate the gross pay well it seems it does but not correctly. The gross pay is coming back as "-9.25596e+061" it worked fine before I added arrays. I do have a text file with the following input :

John Doe 1404 45 20 H
Bobby Jill 1404 45 20 S

#include <iostream>//including library (directive header file)
#include <windows.h>//makes console look pretty
#include <fstream>//Library to read files
#include <iomanip>
using namespace std;
int main() {
SetConsoleTitleW(L"Payroll System");//Set Console Title

[Code] .....

View 2 Replies


ADVERTISEMENT

C++ :: Net Pay By Pass Referencing A Gross Pay Overloaded Function

Oct 23, 2014

I need to return taxes paid and net pay by pass referencing a gross pay overloaded function. Are the values returned from calling the overloaded function file stream objects? Can they be passed simply through a pass-by-reference function?

//Read Data from File, gather info and calculate pay, output data to file
while(counter < x) {
inFile >> last_name >> first_name >> hours_worked >> hourly_pay;
outFile << first_name << " " << last_name << " ";
outFile << calculate_gross_pay(hours_worked,hourly_pay);
counter++;
outFile<<endl;

[code].....

View 8 Replies View Related

C++ :: Find Total Gross For Department Entered

Apr 24, 2013

I am trying to find total gross for department entered but it keeps giving me a total gross for every department and I don't want that. I think its maybe just one word I am missing but not sure. Here's my code

// display record by searching by dept number
void searchByNumber(Staff s[] ,int row) {
double GrandTotalPay=0.0;
clrscr();
cout << "this is Search

[Code] ....

View 2 Replies View Related

C/C++ :: Program That Will Read Gross Salary Of Employee And Calculate Net

Sep 14, 2012

I have tried different programs and nothing works for this.Write a program that will read the gross salary of an employee and calculate the net

View 1 Replies View Related

C++ :: Program To Take Number Of Hours Worked And Output Workers Gross Pay

Sep 21, 2014

ok so i did a program that will take the number of hours worked in a week annd the number of dependents ans inputs and then outputs the workers gross pay, each withholding amount, and the net take home pay per week.

The Program should come out as this:

Regular Hours :34
Overtime hours: 0
gross pay : $323.00
social tax: 19.38
federal tax: $45.22
Statte tax: $16.15
Number of dependents covered: 2
additional health insurance expence: $0

Net take home pay: $236.25

The employer pay rate is 9.50
the employer worked 34 hours "regular hours 40 or less"
if any hours are paid at over time rate of one and one half time that from the gross pay, 6% of social is with held, 14% form federal income, 5% from state income, 6$ per week from union dues, and if worker has 3 or more covered dependent, then an additional 10$ is wothheld to cover the extra cost of health insurance

heres my program:

#include <iostream>
using namespace std;
int main () {
int regHours; // Regular Hours
float hourlyPay, gross, otime, socialtax, federaltax, statetax, uniondues, dep, health; // gross income, overtime, social tax, federal tax, state tax, union dues, depen covered, health insurance

[Code] .....

the program runs but theres still errors in it, it did not make some of the calculations right.

What formula do I use to calculate overtime hours if there was over time?
What formula do I use to take out union dues from total income?
How to I set the number of independents covered to match the health cost if it was 3 or more?

View 1 Replies View Related

C :: Values Are Not Calculating?

Nov 29, 2013

Finally got a programme partially working, why the values are not showing? Is this down to incorrect formula or i havent declared the values etc?

Code:
#include <stdio.h>
#include <math.h>
float timeconstant(float R, float C);

float R;
float C;
float time_c;

[Code] ....

View 2 Replies View Related

C++ :: Calculating Mean And Standard Deviation?

Oct 21, 2013

I've been trying to calculate the Second standard deviation but the average in the second loop isn't calculating correctly which is causing the standard deviation (method 2) to not calculate correctly. I can't find anything wrong.

Code:

#include <iostream>#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
usingnamespacestd;
int main ()

[Code]...

View 8 Replies View Related

C :: Enter Date - Calculating Next Day

Mar 14, 2013

Currently I am working on a program where you enter in a date 14 03 2013 (Day, Month, Year) and you get the next day. I seem to be coming stuck with months with less than 31 days, and the whole leap year thing. Here is my code so far.

Code:
#include <stdio.h>
int day, month, year, next_day, next_month, next_year, calculation;
int main() {
printf("Enter a date in the form day/month/year: ");
scanf("%d %d %d", &day, &month, &year);

[Code] .....

View 4 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++ :: Calculating Area And Perimeter

Sep 28, 2014

I am having trouble with my C++ program. My program asks the user to enter any number greater than 0 and less than 20, and if the user enters any number(s) outside the acceptable range, the output should display:

input outside of exceptable range > 0 and < 20
length: 1 width: 1 area: 1 perimeter: 1

But in my program, this output displays no matter what the user types (even if the numbers are in the acceptable range, when it should be displaying the length and width the user enters and also displaying the calculated perimeter and area whenever the user enters number(s) in the acceptable range. Here is my code:

#include <iostream>
using namespace std;

float class_rectangle_area();
float class_rectangle_perimeter();
float class_rectangle_length();
float class_rectangle_width();

[Code] .....

View 4 Replies View Related

C++ :: Calculating The Time Difference?

Mar 5, 2014

I want to find out the time difference,say i start walking from my home at 23 hr 10 min 25 seconds and I reach destination at 1 hr 10 min 25 seconds.. I know here the time difference is 1 hr 55 min 55 seconds. But how am I gonna calculate this?

View 3 Replies View Related

C/C++ :: Calculating CPU Processing Time?

Jun 13, 2014

I have a problem with calculating the CPUtime. I am using CPLEX to solve linear programming with 3 diferent algorithms.

1-primal Simplex
2-Dual Simplex
3-Barrier Method.

When I am trying to use Barrier method, my clock does not give me a right processing time. I don't have any problem with the other two methods. The value I am getting from ticks2 is 0 when I am using Barrier solver unlike the two other methods that I am getting some small values (ticks1 is fine). Using time_t ticks1 , ticks2 and time(&ticks1) and finally difftime(ticks1,ticks2) also gives me an integer number which is not precise enough. I need a way to compute cputime with accuracy of at least 2 decimals.

clock_t ticks1,ticks2;
double solvingtime
if (solver.primopt==1){
ticks1=clock();
status=CPXprimopt(myEnv, myLP);
ticks2=clock();

[code]....

View 1 Replies View Related

C/C++ :: Calculating Grade And Average?

Dec 10, 2014

Write a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The data in the output file will be nearly the same as the data in the input file except that you will print the names as last_name, first_name and there will be one additional number at the end of each line: the average of the student's ten quiz scores.

The output file must be formatted such that first and last names appear together in a left justified column that is 20 characters wide where the last name comes first, then a comma and a space and then the first name. Use your read string function to read each name separately and then put them together into a larger correctly formatted string before trying to output them. Each quiz score should be listed in a right justified column that is 4 characters wide, and the average should appear in its own right justified column that is 10 characters wide.

Note that if a student has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10; these students are assumed to have missed one or more of the quizzes. The output file should contain a line (or lines) at the beginning of the file providing appropriate column headings.

This is how much I have so far:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char* read_string(char* buffer, int max_size, FILE* fp);
int main(int argc, char *argv[]) {
FILE *fp_input, *fp_output;

[code]....

View 7 Replies View Related

C# :: Calculating Min And Max Values In Array?

Nov 20, 2014

my code is working as expected except a slight error, i have to find min max and median values of an inputed array terminated by 0, the problem im having is with calculating the minimum, where when i enter 0 to terminate the program it uses 0 as the minimum value. my code is as follows

public static void FindAverages()
{
try
{

[Code]....

View 3 Replies View Related

C/C++ :: Calculating Hypotenuse Of A Triangle

Apr 3, 2014

I wrote a function to calculate the hypotenuse of a triangle. My code looks fine but when i enter the two sides it does not give out the right answer. I really don't know what to do.

#include <stdio.h>
#include<Windows.h>
#include<math.h>
double hypotenuse(double side1, double side2);
int main(void){
double side1, side2, hyp;

[Code] .....

View 8 Replies View Related

C++ :: Calculating Average Using Two Different Functions

Mar 16, 2013

When I compile my code with g++ I get the error: constructor, destructure or type conversion missing before sum.

int sum(int,int);
void sum(int,int,int&);
main()
sum (v) // This is the line that the compiler is reporting the error occurs.
answer sum()
int main(){
int a=1;
int b=2;
int sum;

[Code] ....

View 12 Replies View Related

C :: Calculating First Tuesday Of Any Month In Given Year?

Jul 1, 2013

I'm trying to determine the first Tuesday of any month in a given year.. I'd prefer to use my own functions to arrive at a solution, but logically I could sorting these things out.

View 6 Replies View Related

C :: Calculating Distance Between Two Points (x And Y Vars)

Feb 23, 2013

As homework we were assigned to enter the following code to calculate the distance between two points on the x and y plane. The program should ask the user to enter two points then should calculate the distance between two points and print the distance on the screen.

My program will compile correctly but when attempting to run the actual program it doesnt do anything and some how completely skips over my main function...

Code:

#include <stdio.h>
#include <math.h>
struct point {
float x;
float y;

[Code] ....

View 2 Replies View Related

C++ :: Fwrite - Calculating Elapsed Time

Jan 24, 2013

I have a question. I would like to actually have some measure of roughly how long it takes to do a fwrite to a drive. When I do the following:

clock_t begin = clock();
unsigned long long size_t = fwrite(send, 1, transfer_size*sizeof(unsigned long long), wpFile);
clock_t end = clock();
double long elapsed_secs = double long(end - begin) / CLOCKS_PER_SEC;

Unfortunately, I don't get any different result for different transfer size!!!

My guess is that the clock_t , once it issues a fwrite command, some how stops its measurement, and it comes back again, when I am already done with fwrite. I do get the almost same measure, whether my transfer size is 32KB Byte or 16MB ! Which I was indeed expecting to see a huge difference. I wouldn't really want the exact real timing measure (well off course it will be nice to know); and all I care about is to see some difference in time whether I am doing KB transfer vs MB transfer.

Some rough measurement required of the actual time being elapsed for fwrite function?

View 10 Replies View Related

C++ :: Calculating Equation Using Expression Builder

Jan 22, 2014

How do to calculate the following equation"5+((56+8)/2)" using expression builder

Note: the equation may change "50+((26+8)/12)"

View 1 Replies View Related

C++ :: Calculating Standard Deviation From File

Mar 21, 2014

Here's my attempt:

input.open(name);
if (input.fail()){
cout <<"Error opening file"<<endl;
}
while (input>>numbers)
{
counter++;
total += numbers;

[Code]...

Copy of the output:

Error opening file
The Standard Deviation of all the numbers is: -9.25596e+061
Press any key to continue . . .

Its not giving me the right answer.

View 1 Replies View Related

C++ :: Pointer With Array - Calculating Row And Column Sum

Jul 20, 2014

I have two doubts in the following code,the doubts are marked..PLs note that the following code is correct .This is a program to read 2d array using pointer ()i.e Dynamic array ,to calculate its rowsum and column sum and display this array along row sum and column sum.

#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
int *Val,*Rsum,*Csum;
int MaxR,MaxC,i,j;

[Code] .....

View 2 Replies View Related

C++ ::  Calculating Sum Of Square Of Numbers Between Two Inputs

Mar 28, 2014

Write a function which takes two parameter of integer type and both parameters are positive integer. These number should be provided by the user of your program. The first parameter is lower than the second parameter. You function should be able to calculate the sum of the square of each of the numbers between the two inputs and should display that. Please write a main function to display the working of your function. Call the function at least three times by using some loop in the main function.

This is what I came up with but it is not correct:

#include <iostream>
using namespace std;
void sumsquares(int number1, int number2) {
int sum = 0;
for(int i = number1; i<number2; i++)
sum =sum+ i*i;
cout<<"The Result is: "<<sum<<endl;

[Code] .....

View 2 Replies View Related

C++ :: Calculating Net Pay - Adding Basic Procedures?

Nov 18, 2014

So I am currently in the middle of learning c++ and I decided to jump ahead of the book and tried to do add procedures. My goal is to have main calling other procedures such as welcome message().

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

#define MIN_HOURS 0.00 // minimum hours per week
#define MAX_HOURS 60.00 // maximum hours per week
#define MIN_RATE 0.00 // minimum pay rate
#define MAX_RATE 99.99 // maximum pay rate

[Code] .....

View 5 Replies View Related

C++ :: Calculating Greatest Common Divisor?

Jan 12, 2013

I have written the following function to calculate GCD of floating point numbers, but when I run this for (111.6, 46.5), the calculation of fmod(a,b) in the funciton starts giving the wrong result after 2 recursive calls. I am unable to find the error here.

float gcd(float a, float b){
if (a>b) {
if(b==0){

[Code]....

View 1 Replies View Related

C++ :: Program Is Not Calculating Sums Correctly?

Jun 20, 2014

I am getting this weird error when calculating sums. Here is what my program does: it generates two random numbers and then randomly puts either an addition or subtraction sign between the two and then I am asked to enter what the correct answer for that question is. But on some of the subtraction questions when I give the answer it says I got it wrong after which the program shows the right answer. What's confusing is that the answer the computer calculates is the same that I entered. Anyways the complete program and a screenshot of the console window which shows the error are below. The function in question here is decAddSub at line 54. The error is shown in the first sum in the output window. It doesn't affect addition problems and only affects some of the subtraction problems.

#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<random>

[Code].....

View 2 Replies View Related







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