C :: Program To Calculate Business Days In A Year

Nov 11, 2014

I need to make a program to calculate the business days (Monday-Friday) in a year in C. As example:

Input
2026
Output
261

I need to consider that the year could be a leap year and that every year can start with a different day. My Problem is that i dont know how to implement the right number of business days in C. I wrote down the business days in Excel for 2010-2040. I cant see any system behind it, some years have 261 business days, some have 260 or 262 but in no order.

View 7 Replies


ADVERTISEMENT

C++ :: Calculate Number Of Days Between Dates - Program Continuously Runs

Mar 24, 2014

I have an assignment to write a program that will calculate the number of days between two dates (including leap years). We have to read the data from a file and in my current input file I have:

1 1 2000 1 5 2004
5 2 2005 2 5 2009
1 15 1998 1 15 2001

for testing purposes. When I run the program the console runs continuously spouting out "The days between your two dates are 1097." Which would be the correct output for the last set of dates entered, but I need to find out where I've messed up in my main.

#include <iostream>
#include <fstream>
using namespace std;
bool isLeap(int x) {
if (x % 400 == 0) {

[Code] .....

View 7 Replies View Related

C++ :: Calculate User Birthday In Months / Days / Hours And Minutes From Today Date

Jul 24, 2014

The problem is that I need to figure out the user's birthday in months, days, hours, and minutes from today's date.

Here's what I have so far.

#include<iostream>
#include<cmath>
#include<ctime>
using namespace std;
int main() {
int todayDay, todayMonth, todayYear;
int birthDay, birthMonth, birthYear;

[Code] ....

I haven't initialized all the variables, yet. And it's very unfinished. I need to figure out how to convert years from the age into months only. And I need to figure out how to calculate the hours, seconds, and minutes.

View 3 Replies View Related

C/C++ :: Output Number Of The Day Based On Month Day And Year - Check Leap Year

Feb 14, 2015

Whenever I run the program I get no errors yet it doesn't return a value for total it just exits the program. The program is supposed to output the number of the day based on the month day and year and check whether it is a leap year.

#include <iostream>
using namespace std;
int totaldays();
int days();
int month, day, year;
bool leap();
int main() {
char dash;
cout << "Enter the date in mm-dd-yyyy format to find out what day this is in the year." << endl;

[Code] ....

View 2 Replies View Related

C/C++ :: Day Of The Year Program

Nov 5, 2014

I have this project, The problem is I have most of the code written, I am just having trouble setting it up correctly and placing it correctly. My code is rather long but as I said I know this is the longer and harder way to go about this.

//This program will be used to find out the day of the year
#include <iostream>
int month, day, year;
bool isALeapYear(int year) {
//Check if the year is divisible by 4 or is divisible by 400

[Code].....

View 14 Replies View Related

C++ :: Program To Generate Calendar For A Year

Oct 15, 2013

Problem: Write a program to generate a calendar for a year. The program should accept the year and the day of the week for January 1 of that year (0 = Sunday, 1 = Monday, etc.). The calendar should be printed in the following form:

January
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
February
1 2 3 4 5

I have wrote code that has three functions, one to print the month, one to print the days in month, and one to find if it is a leap year or not. I have gotten up to the point where I can print the 12 months with a for loop, but how to print out the days in the format above.

This is my code.

#include <iostream>
using namespace std;
void printOneMonth(int month, int& dow, int year);
void daysInMonth(int month, int year, int& dim);
bool isLeapYear(int year);
int main(){
int year=0, dow, count;

[Code]...

View 1 Replies View Related

C++ :: Program To Check The Leap Year

Oct 7, 2013

Check the Leap Year Program In C++:

#include <iostream>
using namespace std;
int main() {
int yr;
cout << "Enter year : ";

[Code] ....

Check the LeaP Year... [URL] ....

View 2 Replies View Related

C++ :: Days Of Week Program

Feb 10, 2015

I am in a computer science class at LSU and i can not figure out how to writhe this program. The program must let the user input (MM/DD/YYYY) and then output what day that date was on and also if it was a leap year or not.

View 1 Replies View Related

C :: Program That Determine Day Number In A Year For A Date?

Oct 21, 2013

Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1st, 1994, is day 1. December 31, 1993, is day 365. December 31, 1996 is day 366, since 1996 is a leap year. A year is a leap year if it is divisible by four, except that any year divisible by 100 is a leap year only if it is divisible by 40. Your program should accept the month, day, and year as integers. Include a function leap that returns 1 if called with a leap year, 0 otherwise. Extend the requested solution so that your program continues to prompt the user for new dates until a negative year is entered. This is what I have so far.

Code:
#include <stdio.h>
#include <stdbool.h>
int main(void) {

int d,m,y;
int days=0;
int k;

[Code] .....

I am unsure how to make this a loop so that it keeps asking for dates?

View 9 Replies View Related

C++ :: Program To Convert Timestamp To Hour And Days

Jan 17, 2015

I need to write a program that converts timestamp to hour and days.

View 2 Replies View Related

C :: Program To Show Highest Negative And Lowest Positive Temperature Of Year

Jan 19, 2014

I have an assigment and I don't know yet how to write this program :" I introduce the average monthly temperatures of a year(12 values for 12 months). When I compile the program it needs to show the highest negative temparature and the lowest positive temperature of that year.

Example: Entry data: -4 -6 0 5 10 20 24 25 17 8 -1 -7 exit data : max negative= -1 and min positive= 5 "

View 11 Replies View Related

C/C++ :: Vectors And Strings - How To Store Added Business / Sorting It And Displaying List

Feb 18, 2014

Basically I need to make a program which asks for a business name and then keeps asking for more until user doesn't want to. Once more than 1 business is enter it should display the business and sort it alphabetically and keep displaying them each time another is added. I am lost on how to store the added business, sorting it and displaying the list.

Here is what I have so far.

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main () {
string business_name;
char selection;

[Code] .....

View 5 Replies View Related

C++ :: Program That Outputs Calendar For That Month When Given Month And Year

Mar 17, 2013

i am beginner in c++ , i need to write a programm that out ouputs a calender for a month when given a month and year using this frame work :

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;

[code].....

View 8 Replies View Related

C++ :: Show Weekday For Given Year

Jan 23, 2013

I have been given an assignment which I have big troubles with. The assignment is:

"If I ask you “When is the weekday of the 2nd of August in 1429?”, you can answer immediately with your program to my question.

The initial value for the 1st of January in (the year) 1 will be sought by inducing, for example the crucifixion of Jesus is said to be held on Friday, the 3rd of April, AD 33."

How can I solve this?

View 3 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++ :: Program To Calculate BMI

Oct 7, 2013

I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2

Here is my code

#include <iostream>
#include <cmath>
using namespace std;
int main() {
int weight;
int height;
double BMI;

[Code] ....

View 2 Replies View Related

C++ :: Program To Calculate Fractions?

Oct 24, 2013

I need to write a program that can calculate fractions.

View 2 Replies View Related

C++ :: Program That Calculate Discounts

Nov 8, 2013

So my midterm exam for programming is done. My program didn't run. Tried rewriting it once I got home. I am still getting an error that the program could not be run. Also, we weren't allowed to use the internet. So I didn't know how to calculate for the discounted rate.

I am using Microsoft Visual Studio 2010.

Given problem:

ABC Hotel offers 5-10% discounts depending on how much money has the user spent. If item purchase is lesser than 1000php (1USD is 43.19PHP) 5% discount is availed. Greater than 1000php then 10% discount is availed. Total price and discounted price should be displayed.

#include<iostream>
using namespace std;
main() {
float a,b,c,d,e,f,g,h,i,j,total,discounted_price;
cout<<"Please input price of first 1st item: ";

[Code] .....

View 1 Replies View Related

C++ :: Printing Number Of Days In A Month

Dec 17, 2013

I write this program to print the number of days for the month when the year and the month enters. This is not giving any result and i think that problem is with calling functions.

#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int leap_year(int year);
string days(string mounth);
string feb(string fab1);
void main(){
int year;

View 8 Replies View Related

C++ :: How To Search And Display The Total Between 2 Days

Apr 25, 2013

how to search and display the total between 2 days without using lots of code

View 3 Replies View Related

C++ :: Generate Calendar For A Year - Day Of Week Month Starts From

Oct 18, 2013

So for my C++ class I am required to create a program that will "Write a program to generate a calendar for a year. The program should accept the year and the day of the week for january 1 of that year (0=Sunday, 1=Monday, etc.)" (problem statement) and I am completely stuck. I've posted what I have so far below:

#include <iostream>
#include <iomanip>
using namespace std;

bool isLeapYear(int year);
int daysInMonth(int month, bool lpYear);
int printCalendar(int month);
int printDay(int dow);

[Code] .....

View 3 Replies View Related

C++ :: How To Print Any Input Year In Digital Block Form

Apr 29, 2013

How to print a year like DIGITAL CLOCK NUMBER for any input four digit number ...

For example if input 1000 the output should be 1000 but each number should look like this in the block form for example number 0 is, don't mind those stars, i did not know to print it here, that is number zero ...

======
=****=
=****=
=****=
======

View 1 Replies View Related

C/C++ :: Compare Time Fetched From Two Week Number Of Different Year?

Jul 5, 2012

How to compare the time fetched from two week number of different year using C,C++.

I have used a naming convention for the files generated in a linux system. The naming convention will have the week number and date's day indication like Monday means M. I need to compare the two files of same week but on different years and calculate the time?

View 1 Replies View Related

C :: Calculate Offset Of Simple Program

Sep 28, 2013

I would to learn how could i calculate the offset of simple c program?

Lets say that I have that simple program:

Code:
#include <stdio.h>
int main() {
int x=1;
printf("x = %d", x);
return 0;
}

View 9 Replies View Related

C :: How To Write A Program That Will Calculate Stress

Feb 7, 2013

I recently signed up for ES201 class and am confused with how to compile a program in the C language that will convert ACT scores to SAT scores.

View 5 Replies View Related

C :: Program That Will Calculate Strain Of Object

Feb 7, 2013

The equation for strain is:

delta(x)/x_0
delta(x) is the change in length of the rod(final length - initial length) x_0 is the original length of the rod

I'm trying to figure out how to write a program that will calculate the strain of an object, given its initial length and final length.

View 2 Replies View Related







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