Option to input employee information

Assignment Help Business Management
Reference no: EM132140433

This is some code I have been working on. It is a menu with an option to input employee information and a table to view it in. The code works for the most part - except after you have filled the maximum number of employees and attempt to insert another one and the correct error message appears. Then, when the option is selected to display the employee's information, it will only correctly show the last employee entered and the rest will all be 0s. I haven't the foggiest where the issue is. Any hint would be appreciated. I am not asking for the answer I'm asking to be pointed to the section of the code that is causing this extremely specific issue. To narrow it down.

#define _CRT_SECURE_NO_WARNINGS

#define SIZE 2

#include <stdio.h>

// Define Number of Employees "SIZE" to be 2

// Declare Struct Employee

struct Employee {

int id, age;

double salary;

};

/* main program */

int main(void) {

int option = 0;

// Declare a struct Employee array "emp" with SIZE elements

// and initialize all elements to zero

struct Employee emp[SIZE] = { { 0 } };

int counter = 0;

int employeesNumber = 0;

printf("---=== EMPLOYEE DATA ===---nn");

do {

// Print the option list

printf("1. Display Employee Informationn");

printf("2. Add Employeen");

printf("0. Exitnn");

printf("Please select from the above options: ");

// Capture input to option variable

scanf("%d", &option);

printf("n");

switch (option) {

case 0: // Exit the program

break;

case 1: // Display Employee Data

// @IN-LAB

printf("EMP ID EMP AGE EMP SALARYn");

printf("====== ======= ==========n");

// Use "%6d%9d%11.2lf" formatting in a

// printf statement to display

// employee id, age and salary of

// all employees using a loop construct

if (emp[0].id > 0) {

for (counter = 0; counter < SIZE; counter++)

printf("%6d%9d%11.2lfn", emp[counter].id, emp[counter].age, emp[counter].salary);

printf("n");

}

// The loop construct will be run for SIZE times

// and will only display Employee data

// where the EmployeeID is > 0

break;

case 2: // Adding Employee

// @IN-LAB

printf("Adding Employeen");

printf("=============== ");

// Check for limits on the array and add employee

// data accordingly.

if (employeesNumber < SIZE) {

printf("nEnter Employee ID: ");

scanf("%d", &emp[counter].id);

printf("Enter Employee Age: ");

scanf("%d", &emp[counter].age);

printf("Enter Employee Salary: ");

scanf("%lf", &emp[counter].salary);

printf("n");

employeesNumber++;

}

else {

printf("ERROR!!! MAXIMUM NUMBER OF EMPLOYEES REACHEDnn");

}

printf("n");

break;

default:

printf("ERROR: Incorrect Option: Try Againnn");

}

} while (option != 0);

printf("Exiting Employee Data Program. Good Bye!!!");

return 0;

}

Reference no: EM132140433

Questions Cloud

Legal implications for inaccurate or misinformative speaking : Examine the guidelines for informative speaking and discuss the potential ethical or legal implications for inaccurate or misinformative speaking.
Making a vbscript script : Help with making a VBScript script (w2_firstname_lastname.vbs) that takes 3 parameters (numbers)
How could you have altered the framing of the situation : Find at least one example from your own career where you, or another manager, allowed one of these or another pitfall, to sway you from the mean.
Statements is true in the context of employee separation : Which of the following statements is true in the context of employee separation?
Option to input employee information : This is some code I have been working on. It is a menu with an option to input employee information and a table to view it in.
How your program will seek to address the difficulties : Outline a mental health program to treat the primary psychopathologies of mentally disordered offenders, including schizophrenia, major affective disorders.
How much tax was actually paid : Its income statement for the year to 30.6.X5 includes a tax charge of £400,000. How much tax was actually paid in the year to 30.6.X5
Identify the major trends in general environment : Discuss and describe the six elements of the external environment. Please identify the major trends in the general environment.
What is the precision and recall of our spam detector : Suppose we have a dataset with 500 spam emails and 500 non-spam emails. When we apply our learned model to this dataset, suppose our model correctly

Reviews

Write a Review

Business Management Questions & Answers

  Caselet on michael porter’s value chain management

The assignment in management is a two part assignment dealing 1.Theory of function of management. 2. Operations and Controlling.

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. Due to increase in the preference for light beer drinkers, Chris Prangel wants to introduce light beer version in Mountain Man. An analysis into the la..

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. An analysis into the launch of Mountain Man Light over the present Mountain Man Lager.

  Analysis of the case using the doing ethics technique

Analysis of the case using the Doing Ethics Technique (DET). Analysis of the ethical issue(s) from the perspective of an ICT professional, using the ACS Code of  Conduct and properly relating clauses from the ACS Code of Conduct to the ethical issue.

  Affiliations and partnerships

Affiliations and partnerships are frequently used to reach a larger local audience? Which options stand to avail for the Hotel manager and what problems do these pose.

  Innovation-friendly regulations

What influence (if any) can organizations exercise to encourage ‘innovation-friendly' regulations?

  Effect of regional and corporate cultural issues

Present your findings as a group powerpoint with an audio file. In addition individually write up your own conclusions as to the effects of regional cultural issues on the corporate organisational culture of this multinational company as it conducts ..

  Structure of business plan

This assignment shows a structure of business plan. The task is to write a business plane about a Diet Shop.

  Identify the purposes of different types of organisations

Identify the purposes of different types of organisations.

  Entrepreneur case study for analysis

Entrepreneur Case Study for Analysis. Analyze Robin Wolaner's suitability to be an entrepreneur

  Forecasting and business analysis

This problem requires you to apply your cross-sectional analysis skills to a real cross-sectional data set with the goal of answering a specific research question.

  Educational instructional leadership

Prepare a major handout on the key principles of instructional leadership

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd