C++ :: Adding Employee Names In Function Arranged Program
May 13, 2014
The program that I have written below is working. It calculates a number of payroll type variables and most recently the net pay average (All this is working 100%).
My problem is that I need to add first and last employee names to the program but every time I do this I end up ruining the working program. I've successfully added first and last names to similar programs in the past(ones that make use of an array and while loop) but never to a program that uses functions (I always have problems doing this).
My question is what codes do I use to add a first and last name variable and where do I put those codes within my program so it runs/displays correctly.
I think the coding must be similar to what I've used in the past charr and of course firstname[i] and lastname[i] lines.
Current Input File:
16454025.00
89324020.00
71044012.50
28164026.00
53874021.00
67804013.50
56414011.25
90006025.00
90015020.00
90025523.00
Ideal input file (would include names) Example.
1645 Bob Smith 40 25.00
I am trying to make a very simple text based game and I want the players to be able to name their characters. Thus, I am trying to have the game ask "how many players will be playing:" and then taking that number (X) and create a place to store that information. I'm trying to get the game to ask, "What is the name of Player1?" Then once the user enters the name it would ask "What is the name of Player2" and that cycle would continue until PlayerX has entered their name. Is what I am doing close?
Here are the errors:
error C2143: syntax error : missing ';' before 'string'(ln 29 col 1) Error2error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'std::basic_istream<char,std::char_traits<char>>' (or there is no acceptable conversion) (ln 30 col 1)
int NumberOfPlayers; if (Response1 == "Yes") { cout << " How many players will be joining us on our adventure: ";
I am having some trouble with my class assignment. We need to write a C program that will calculate the employee salary. There are 5 employees that will need to be calculated. We are required to use a loop also.
So far this is what I have but I am receiving errors when running the program.
#include <stdio.h> int main() { int clock_num; /* employee clock number */ float gross; /* gross pay for week (wage * hours) */ float hours; /* number of hours worked per week */ float wage; /* hourly wage */ /* Prompt for input values from the screen */ printf ("This is a program to calculate gross pay.
Write a payroll program that prompts for the number of hours an employee worked, as well as the employee’s pay rate. If the employee worked for 40 hours or less, the gross pay is calculated by multiplying the number of hours worked by the pay rate. If the number of hours worked by the employee exceeds 40 hours, the employee should receive regular pay for the first 40 hours, and receive time-and-a-half pay for the hours in excess of 40. Display the calculated gross pay on the screen.
Continue to prompt for similar data for more employees and have the gross pay of each employee displayed, until there is no more employee data to process. Then display “Good Bye”.
Your solution must be separated into three source files (Interface, Implementation, and Test)
I am writing a employee payroll program using structures. My program is running but its only showing some of the data.
HERES MY CODE
Code: #include <iostream> #include <cstdio> #include <fstream> #include <string> #include <iomanip> #include <cstring> using namespace std; const int SZ = 20; // size of arrays to hold scores struct payrollStruct {
[Code] ....
And it doesn't show anything from txt file
Code: 40.0 10.00 A1234 Jane Adams 50.0 10.00 L8765 Mary Lincoln 25.5 10.85 W7654 Martha Washington 52.0 15.75 A9876 John Adams 45.0 25.00 W1235 George Washington
I am trying to create an array with 800 element that are randomly arranged within the array. Once this is complete i want to use the bubble sort algorithm to organize the number in ascending order. I have the following code but it doesn't seem to work,
#include <stdio.h> #include <stdlib.h> #include <time.h> #define BUBBLE 800 int main() { int array[BUBBLE];
i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.
void Store::deleteSpecifiedStoreFromList(string choice) { for (int i = 0; i < this->stores.size(); i++) { if(this->stores[i].getStoreNames() == choice) { this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() ); } } }
" Write a program that reads into a string object a name with three blanks between the first and last names. Then extract the first and last names and store them in separate string objects. Write a function subprogram that displays its string argument two times. Call this function display the first name for times and then to display the last name six times."
I completed coding the first part of this task with the strings and combining strings together. However, i have having trouble with the other half of this task. It begins from "Write a function subprogram to display the last name six times." This is where i have so far --
#include <iostream> #include <string> using namespace std; int main() { // Defining the strings
I just recently started looking into C++ programming so I don't know much.
I was wondering is it possible to write a program to pick a random name from a list of names, which are in a .txt file? or if I could ask the user to input the list of names and then let the program pick a random name?
Manually create an input text file called Lab22BInput.txt with the following data:
Dove Doe Alston Zebra Egg
Write a program that will read the names from the input file. Print out each of the names read to the screen. The program should go through the list of names and determine which comes 1st in the alphabet. The program should determine how many letters are in this name. Print out the name that comes first in the alphabet and the length of the name.
I have created the input file, and the data correctly outputs to the screen when I run the program. However, I do not know what kind of logic to use to sort them alphabetically and determine the amounts of characters.
So far I have the following:
#include <iostream> #include <string> #include <fstream> using namespace std; int main() { string str1, str2, str3, str4, str5;
In my class we were supposed to write a program from the book that inputted the names and votes and the program is supposed to spit out who won the vote. I did this then while i was reading the assignment from the instructor I noticed he wanted the information inputted from a TXT file instead of manually inputting it. I cannot seem to get it to work....
#include <iostream> #include <iomanip> #include <string> #include <fstream> using namespace std; #define N 5 char names[N][20]; float votes[N];
[Code] ....
here is the txt file
Johnson 5000 Miller 4000 Duffy 6000 Robinson 2500 Ashtony 1800
'm new to programing and I'm trying to get this program to add up a price of coffee to the add on extras such as cinnamon, etc. But once the program runs it doesn't add up the coffee price with the extras and I've been at it for hours...
Code:
#include <iostream> #include <cstdlib> using namespace std; int main()
I'd like to add a 'command' to my C program. For example if someone types 'get out' it closes the shell and quits. I want the 'get out' command to work like 'exit'. How do I write a code like this
Code: char entry[15]; scanf("%[^ ]", &entry); if (entry = "get out") do "exit";
I am creating a program that allows the user to enter the number of days worked and calculates the amount of money gained by doubling the amount from the previous day, starting with .01 cents. The program works fine except for in day 3, the program adds .01 along with doubling the amount from day 2. Also I must use a List Box.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;
The program below should add two matrices using function. I have problem in the third function (the summing function). It's saying that something wrong with the array! I'm new to arrays and functions.
#include<iostream> #include<fstream> #include<conio.h> using namespace std; int matrix1 (); int matrix1 (); int add ();
But I still do not load the excel file into my program by selecting the program from ContextMenu (right click on excel file and choose program). Although if select the path to excel file from the program, the data from excel file is loaded into the program.
I'm still missing something at function OpenExcelFileWithEasyForm(). How to complete this function to load the excel file into my program when selecting programs in ContextMenu.
I want to be able to keep on adding a row to my datagrid every time i click a button, the row will hold the text of the text box and the combobox in its individual cells, is there a way to do this without inserting a ridiculous amount of code?