C++ :: Create Simple Payroll Management Application Using Concept Of Binary Tree?
Apr 2, 2013
Create an a simple Payroll Management Application using the concept of Binary Tree. The program will allow you to add, sort, view, search record. The application have also the capability to save and retrieve data in a file.
I'm building a simple system management console application. I've abstracted the console "Menu" and derived from it a "WelcomeMenu" class with public inheritance.
The problem is that when instantiating a Menu* object and assigning it a new WelcomeMenu...I'm still not able to use WelcomeMenu's "ShowWelcomeMessage() with the Menu* object. Instead, I get "error: Class 'Menu' has no member function call 'ShowWelcomeMessage().' Which is true, but I thought a pointer-to-Menu object should be able to use the public methods of derived classes without casting in this case. Code follows.
// Menu and WelcomeMenu Classes #ifndef MENU_H #define MENU_H
For my data-structures class, I am attempting to create a binary search tree template to be used to create an AVL tree. I've written a Generic_Tree template for the BST to inherit from, and before I jump into implementing the AVL tree I'm testing the BST member functions. Everything was compiling fine until I added the BST insert() function. Now, I'm getting the following error message from my linker:
undefined reference to 'BST<void>::insert(int, void*)'
I am trying to read/write binary trees to a file for a little project I'm working on for fun. I got frustrated and gave up; now, I am trying again! So I am writing the tree to file (or, rather, to string for now) like so:
string wBinTree(node *p) { string str = "";
[Code]....
But now I'm completely lost as to recreating the tree from a string. I thought of perhaps using an array/vector/string of 1's and 0's or trues and falses to keep track of where I was in the tree, but it's really beyond me.
Create a payroll program to store and calculate the payroll for a small company with a maximum of 20 employees.
Program parameters are as follows:
1. Create a menu with the following options (use a do-while loop): A or a to add employee info D or d to display employee info T or t to display total payroll S or s to display the info of all employees Z or z to exit program
The information for each employee is: employee number, hours worked, pay rate per hour, tax deduction.
2. Use an array of doubles to store employee information.
3. Menu option A or a: ask the user for the employee information one value at . a time and store it in the array.
Please enter employee number: 2190 Please enter hours worked: 32.50 Please enter pay rate: 9.25 Please enter tax rate deduction: 5.50
4. Option D or d: ask the user for an employee number as integer and display . the information for the corresponding employee (cast the employee number
. in the array to integer and then compare). If employee number does not . match, output a msg. indicating "no such employee". If the employee number . is a match, output all the employee information stored in addition to the . calculated deduction and salary.
Output sample: Info for employee number: 2190 Hours worked: 32.50 Pay rate: $ 9.25 Tax deduction: 5.50 % Total pay: $ 284.89
5. Option T or t: calculate and output the sum of the total pay of all . employees.
6. Option S or s: display the information for all employees in the same . format as in option B.
7. Option Z or z: exit the program.
#include <stdio.h> #define MAX [20] int main(void) { int i; for (i=0;i<=20;i++) { char MenuOption=0; int EmployeeNumber;
The code meant to generate a simple tree. As you can see from the output, somewhere the parent pointers get messed up. And yet, I can't seem to find where, and if I output them in the constructor (only time they get modified) they all look OK. When I run output_path_to_root() on any grandchildren of the root I get a segmentation fault. How the parents are getting messed up? I was wondering if my vectors changing size is causing pointers to shift around but I'm not sure.
//tree.cpp
#include <iostream> #include <vector> using namespace std; struct A { int n; vector<A> get_children() {
I'm building a Windows Form Application using MVP Design Pattern; the application is quite simple, it just calculates the sum of two number; So I have a form in which are located tree textbox: number1 number2 and result, plus a button to perform the action.
I am learning c because I want to get back into programming microcontrollers, which I previously did in assembly. I wanted to make something fairly tight in terms of program memory and RAM to show me an output in binary form. When you are troubleshooting a file register or serial interface when you can see the actual bit values (on a small LCD for a micro-controller) and compare it to a datasheet.
Code: #include <stdio.h> #include <math.h> int main() { int i; int decimaltoconvert; int convertingarray[7]; int convertingarray2[7];
[Code] .....
Also, how might I go about putting that into a function that I could call?
Write a program to do simple encryption and decryption. Encryption basically means to convert the message into unreadable form. In this assignment, it should be done by replacing each letter of a message with a different letter of the alphabet which is three positions further in the alphabet. Then, all the letters will be reversed. Decryption is the process of converting encrypted message back into its original message. Your program should use the following shifting method.
Note: You must use array.
#include <iostream> #include <string> using namespace std;
It has been a while since I built a binary tree from scratch so I decided to do it. Everything works fine but this one function. When I enter a number to search it just keeps running and allowing me to keep enter numbers.
Code: void tree::search(int key,Node* leaf) { if (leaf == NULL) { std::cout<<"The tree is empty
I have a problem with the C code . I created two functions, one that runs through the tree inorder, the other that returns the maximum value in the tree. The problem is when I use in the main the method "max", which goes in a loop and not print anything on the screen . If I remove the call to method "max" it works fine. Here's the code:
Code:
#include<stdio.h> #include<stdlib.h> #define bool int /* A binary tree tNode has data, pointer to left child and a pointer to right child */ struct tNode {
I've almost got my code working. My issue is, if I type in either one of the first two id numbers, it finds the person and displays as it's supposed to, however if I type any of the last 6 id numbers it says id not found. I've been staring at this forever and can't see what I'm missing />/> ps, I haven't added in all my comments yet Binary tree template
//Binray tree template class #ifndef BINARYTREE_H #define BINARYTREE_H
I need to write a program to find the sum of depths of a binary tree, where a depth is by definition the shortest distance between a node and the root. I am required to code this using recursion.
I was thinking of first coding a helper recursion to find the depth for each node. What would be the best way to do that? If I could move from the node to the root, I believe programming this helper recursion would not be very difficult. Is there a way to progress from the node to the root?
I am having trouble with my deleteNode function, using recursion I am trying to delete a node from a binary tree. My tree is displayed as the following...
Tree: (node)->[left child, right child] (k)->[g,p] (g)->[c,h] (c)->[ ,e]
[Code]....
The result did show that it is erased but when I try to add the erase node "t" back into the tree it still exist. I am stumped on what to do when using recursion way of deleting node.
template <typename T> void insert(BTree<T>* tree, T item) { if (tree == nullptr) { tree = new BTree<T>(item); } else if (item < tree->val) { insert(tree->left, item); } else { insert(tree->right, item); } }
I think this function may not be working because I am modifying `tree`, which is a local variable. How do I actually modify the current pointer that `tree` represents, not just `nullptr`?
How to store values from a .txt file delimited with semicolons (;) into a class which is then stored into a Binary Search Tree. After browsing Google for a few hours, and trying various examples of people using Vectors, I just can't seem to get my program to work using Object Oriented Programming with an instance of the class Person.
My two classes are Person, and BinarySearchTree as follows:
class Person{ private: string first_surname; string second_surname; string name; int ID;
[Code] ....
Ok so my text file saves the data of each person in the same order as the class with each value separated by a semicolon.
i.e. First_Surname;Second_Surname;Name;ID;Telephone;Score;
void fillTree( BinarySearchTree *b) { string input[7]; Person p; fstream file("scores.txt", ios::in); // reads text file if(file.is_open()) {
[Code] ....
I understand that I get an error because a vector is saved as integers, and I am using strings, my question is, any other way to read the .txt file and save each data separated by a semicolon, into the Person class?