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


ADVERTISEMENT

C++ :: Write Program To Convert Time From 24-hour Notation To 12-hour Notation

Dec 10, 2013

Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)

Answer:

#include <iostream>
#include <iomanip>
#include <cmath>

[Code]....

It is showing error because may be I was not able to put that if statement inside any function. find out the error sand complete the program with corrected code.

View 2 Replies View Related

C/C++ :: 24 Hour To 12 Hour Conversion?

Nov 5, 2014

this runs and everything just fine, however i cant seem to figure out why the program isnt telling to user to use a valid time for hours and minutes when it's entered over the standard time limits (i.e. cant go over 23 hours and over 59 minutes)

#include <iostream>
using namespace std;
//functions for converting 24hr to 12hr notation
//parameters use int and void as a data type

[code]....

View 1 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 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 View Related

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++ :: Compiling Errors With Timestamp Code?

Mar 28, 2013

I've written a simple program that output's my name, course, and a time date stamp.

Having researched the code to do so, I've used the includes for both the ctime and time.h libraries.

I leveraged localtime_s and asctime_s to actually convert to string etc., and the program runs fine when I step through it in Visual Studio.

However, we're working with CGI and this program will ultimately be called up from the cgi-bin directory of a web server. The first thing that needs to be done after copying it to the webserver is to compile it. That's where my problem occurs.

Using the console command: g++ lab5a.cpp -o lab5a.exe the file is supposed to compile and be converted to a .exe.

However, instead I receive errors:

localtime_s was not declared in this scope
asctime_s was not declared in this scope

I "believe" it's because of the included libraries, but not sure.

They are:

HTML Code:
#include <iostream>
#include <ctime>
#include <time.h>

Here's the actual timestamp block of code:

HTML Code:
//Begin date and time instructions
time_t curTime;
struct tm locTime;
const int TimeStrLen = 26;

[Code] ....

Of course, I go on to error check and complete the block, but you get the picture.

View 5 Replies View Related

C/C++ :: How To Calculate NTP Timestamp To Unix Epoch Time

Mar 18, 2015

I have been trying for several months to create a simple SNTP single Client/Server based on RFC5905. Finally I manage to make it work at least I think it works correctly, but when I tried to test my code against a real NTP server (e.g. 0.se.pool.ntp.org:123) the timestamps that I am receiving need to be recalculated. I have tried several different approaches but no matter for 3 days now but no matter what I tried nothing yet.

The problem that I am having in not so much programming error is more about knowing how the NTP server operates.

How to convert the NTP timestamp to Unix epoch timestamp?

Syntax to execute the Server e.g. ./server 127.0.0.1:5000 and Client e.g. ./client 127.0.0.1:5000

Syntax to execute the Client against a real NTP server e.g. ./client 0.se.pool.ntp.org:123

Sample of working code Client:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>

[code]....

Sample of printed output when I use Server and Client.

Reference Identifier 0 LOCL
Reference Timestamp 0.0 1426637081.3564398733
Originate Timestamp 1426637087.3570333925 1426637087.3570333925
Receive Timestamp 1426637087.3570334078 1426637087.3570334003
Transmit Timestamp 1426637087.3570333925 1426637087.3570334046

Sample of printed output when I am probing a real NTP server (e.g. 0.se.pool.ntp.org:123).

Reference Identifier 0 $
Reference Timestamp 0.0 3879449560.3503094062
Originate Timestamp 1426637090.3573978972 1426637090.3573978972
Receive Timestamp 1426637090.3573992772 2722083800.781009125
Transmit Timestamp 1426637090.3573978972 2722083800.937312997

View 2 Replies View Related

C :: Make Difference Between Hours And Hour?

Oct 6, 2013

I'm writing a program that converts seconds to hours and minutes - That works fine! But if I write: 3700 seconds It answers That equals to: 1 hours, 1 minutes and 40 seconds.

I now want my program to write 1 hour, 1 minute and 40 seconds.

And if there is no hours at all it should only write 400 seconds equals 6 minutes and 40 seconds.

To sum up: The program shall write hour/hours minute/minutes second/seconds correct.

I've made one succesfull program, but it was written with 27 "if-statements" and I know there is a better way.

Code:

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

[Code]...

how to make the program know when to write hour or hours?

View 10 Replies View Related

C++ :: How To Create Count Down Timer For 1 Hour 30 Minutes

Apr 7, 2014

I want to add a count down timer to my testing software 1hr and 30min

Its a 32bit console application, I want the countdown timer outputted above each question on the right side, timer only needs to output the time left at the top of each question so a live outputted timer is not important.

Questions are not random generated.

Also how to output "out of time" if the timer reaches 0 and for the test to end, I think branching is involved not too sure.

I already have, std::srand( std::time(0) ) ; at the start of the test to randomly generate the answer order.

View 10 Replies View Related

C/C++ :: Converting Miles Per Hour To Seconds Per Mile

Oct 4, 2014

I have to program something that would convert miles per hour to seconds per mile.

I'm having an issue with something that I coded. Lines 21-23 are not showing up when I compile the program. What I'm trying to do is convert seconds into minutes.

What I have so far is

#include <iostream>
using namespace std;
int main() {
double miles_per_hour, minutes_per_hour, seconds_per_hour, seconds, minutes;
cout << "Enter the miles per hour: ";
cin >> miles_per_hour;

[Code] ....

View 14 Replies View Related

C/C++ :: Recursive Function To Print Hour Glass Pattern

Oct 11, 2014

I need to make a recursive function(s) which prints the hour glass pattern. This is my code so far:

void HourGlass(int n) {
if (n==1){
cout<<"*"<<endl;
cout<<"*"<<endl;
} else {
stars(n-2);
HourGlass(n-2);

[Code] ....

Problem is, it doesn't print the spaces in front of the pattern. This is what it prints:

*****
***
*
*
***
*****

and this is what it is supposed to print:

*****
***
*
*
***
*****

Do I make a separate function for the spaces? How do I go about it?

View 7 Replies View Related

C++ :: Calculating With Time - Restrict User To Input Minutes 60-99 For Every Hour

Oct 22, 2013

I have to write a program for class in which users will be inputting:

start time = startTime
number of minutes = callDuration

so first off, teacher wants us to input time as a floating point number such as 09.00

How do I validate the time so that users cant input i.e. 09.61 for every hour? In other words, so the user cant input minutes 60-99 for every hour.

then, when calculating:
endTime = startTime + callDuration

how would I make endTime display a correct time in such a situation: endTime = 09.45 + 00.30

so that it displays 10.15 not 09.75

View 4 Replies View Related

Visual C++ :: Calculate Amount Paid To Employee Based On Hours Worked And Rate Per Hour

Oct 8, 2013

Write a program in C++ that calculates the amount to be paid to an employee based on the hours worked and rate per hour. A user will enter hours worked and rate per hour for an employee. Your program should have a function payCheck that calculates and returns the amount to be paid. The formula for calculating the salary amount is as follows: for the first 40 hours, the rate is the given rate (the rate that a user has entered); for hours over 40, the rate is 1.5 times the given rate.

I had write my own coding, but it keeps error. it is okay. But i still don't think i could share here? Still running... I will update my coding for you alls to check for any syntax or logic error. The problem is i need to calculate if the employee work for more than 40 hours which 1.5 times.

Code:
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
using namespace std;
int main(void) {
char *empname, *test, *final_output;

[Code] .....

View 7 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++ :: Function To Find Out How Many Days Have Passed Since Last Birthday

Feb 20, 2013

I have to write a c++ program with my own function which consists of two parameters (day, month). Function have to return number of days since the begining of this year. Using this function i have to find out how many days are left till birthday (or how many days have passed since last birthday)

This is how far i am:

Code:

#include <iostream>
using namespace std;
int cikDienu(int diena, int menesis);
int main()

[Code] ....

View 9 Replies View Related

C++ :: Read Date From File To Determine Different Days?

Mar 22, 2014

How do I read a date from a file to determine different of days

For example my date.txt contains:

1 23/01/2012 05/02/2012

Currently my code is:

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

[Code].....

View 14 Replies View Related

C/C++ :: Read Date From File To Determine Different Days

Mar 21, 2014

How do I read a date from a file to determine different of days

For example my date.txt contains:

1 23/01/2012 05/02/2012

Currently my code is:

#include<iostream>
#include<fstream>
using namespace std;
class Date {
public:
int day;
int month;
int year;
int total_day;
Date();

[Code] ....

View 1 Replies View Related

C++ :: Compare Date And Show Difference In Days

May 20, 2012

I have a file, 'date-list.txt' which has date in it. For example , 20 May 2012 .

Now I want to compare this date with current system date and show the difference in days .

How can i compare dates and shows difference in days in C++.?

View 5 Replies View Related

Visual C++ :: Calculating Number Of Days Between Dates

Mar 19, 2014

I have a code that calculates the number of days between dates. It considers leap years and different days among months. The problem I have is when i debug the code nothing comes out.

Here is the code.
#include<iostream>
#include<fstream>
using namespace std;
bool wheep();
int daysinmonth();
bool wheep(int yr) {
if (yr % 400 == 0)

[Code] ....

this is the file its reading
1 7 9 1 10 9

View 3 Replies View Related

C :: How To Compare Days By Dates Of First Week Of 1997 To 2014

Jan 14, 2014

I want to compare dates of first week of every year input by user to determine that what was the day on 02/01/1998 compare to 02/01/2014, or 04/01/2001 compare to 04/01/2003.

I want to compare from 01/01/1997 , 07/01/2014.

For example user enter first date 04/01/2002 and other date 04/01/2003, then the program show that there was tuesday on 04/01/2002 and monday on 04/01/2003.

[Code] ......

View 5 Replies View Related

C++ :: Create Function That Performs Addition Of X Days At A Time?

Jan 26, 2012

I need to create a function that performs the addition of x days at a time, taking two integer values, the first being a date (yyyymmdd format) and a number of days to add / subtract that date.

How can I perform validation if the entire amount received is a valid date and how can I add x days of that date?

View 8 Replies View Related

C Sharp :: Windows Service To Call Stored Procedure Every 30 Days

Jul 24, 2012

Just now I started learning Windows services.I want to create a windows Service that will call the stored procedure every 30 days.

View 1 Replies View Related

Visual C++ :: Employee Class - Number Of Vacation / Sick Days Used

Oct 21, 2012

Can not even say this is the error as it is giving me 45 errors. l am writing code which accept employee type based on calculating the miles traveled in a year,my code is based on type of employee, number of vacation days used and no of sick days used.

#include <iostream>
#include <iomanip>
#include <conio.h>
class employee {
int emp_type;
float emp_vacation;

[Code] ....

View 11 Replies View Related

C/C++ :: Creating A Class To Store Value That Represents Number Of Hours / Days Worked

Feb 22, 2014

Create a class to store a value that represents number of hours worked and number of days worked. Must ensure that the two representations are always consistent. I have to create 2 files, I'm pretty sure: a .cpp and a .h

This is what I have so far for my .h file (I know it's NOT functional...yet):

#include <iostream>
using namespace std;
class NumDays {
private:
double hours;
double days;

[Code] ...

I don't know how to start / create this .cpp file to define the variables.

View 3 Replies View Related







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