473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Counter problem

I need this program to display the number of vacation weeks based on the number of years an employee has been with a company. It needs to allow me to enter the number of years for as many employees as I like. I would also like it to calculate and display the total number of employees entered.
How do I make code for a counter? And how do I get the error message to work(b/c it's not working as far as I know)? I would really appreciate any advice or help.

#include <iostream>
using namespace std;

int main()
{
int years = 0;
int counter = 1;
int employees = 0;

cout << "Enter the years employed: ";
cin >> years;

while (years != -3)
{
{if (years == 0)
cout << "Vacation weeks: 0" << endl;
else if (years > 0 && years <= 5)
cout << "Vacation weeks: 1" << endl;
else if (years > 5 && years <= 10)
cout << "Vacation weeks: 2" << endl;
else if (years > 10)
cout << "Vacation weeks: 3" << endl;
else cout << "Invalid years" << endl;
}

cout << "Enter the years employed: ";
cin >> years;

}

return 0;
}
Oct 29 '06 #1
2 2772
Banfa
9,065 Expert Mod 8TB
a. initialise you counter variable to 0
b. at the start of the loop increment the counter

counter++;

c. After the loop has finished output the value of counter.
Oct 30 '06 #2
Thank you! :)
Oct 30 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Shane | last post by:
:) I am following a tutorial for php (hudzilla.org) absolutely loving it however I am having trouble with the counter example <?php // your content here... $filename = 'counter.txt'; // our...
2
by: Mike Brearley | last post by:
I have a counter (alright one I found on asp101.com) that checks for a session variable to prevent the counter from incrmenting if a user refreshes the page or returns to the page during the same...
2
by: Ben Barnes | last post by:
Hi, Having an issue with a pretty standard javascript text counter. The counter works fine when a user physically enters text into a textbox but shoudl the textbox have a value prefilled then...
7
by: JellyON | last post by:
Hi. Is there a way to delay a call to a page counter (ie. call to a server script from an IMG tag) for the purpose to not lock the page loading awaiting counter be displayed. Maybe a...
14
by: Newbie | last post by:
Can anyone get this counter working in ASP.NET 1.1 in VB.NET 2003 like in the demo project? http://www.allscoop.com/netcounter.php I can get in to work in ASP.NET 2.0, but not ASP.NET 1.1,...
1
by: jvn | last post by:
I am experiencing a particular problem with performance counters. I have created a set of classes, that uses System.Diagnostics.PerformanceCounter to increment custom performance counters (using...
12
by: devospice | last post by:
Hi, I'm trying to create a download counter for individual files on a web site and I'm not sure how to do this. Right now I'm using Webalizer to just read the log files and see how many times...
1
by: JuAn2226 | last post by:
hi i'm having trouble with my code If lblNumberArray(i) = lbltmpNumber Then EndTime = Now lblEnd(i).Caption = Format(EndTime, "hh:mm:ss") StartTime = lblTime(i) Timeduration =...
9
by: Pygmalion | last post by:
I have found dozen of useful PHP counters on the web. However, nobody is working for my web pages, since administrator does not want to enable the possibility that PHP could be called from HTML. ...
2
by: gumbercules | last post by:
I am designing a site that is regulary updated with new podcasts. I would like to be able to have a counter next to each podcast showing how many hits/listens/plays/views each particular podcast has...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.