C++ :: Class Military To Standard Time
Feb 22, 2012
basically my program lets the user inputs military time( in hour, minute, and seconds). I need to convert this to standard time and have am/pm at the end. Here is what I have so far.
I have a 3 files, time.h, time.cpp (defines functions), and main.cpp (testing). I have a problem in my main function under main.cpp. I don't understand how to set the parameters of the two time objects; t and test. When i do test( hr, min, sec) it shows random numbers when it prints out in standard time.
(HEADER FILE called Time.h)
#ifndef TIME_H
#define TIME_H
class Time
{
[Code].....
View 2 Replies
ADVERTISEMENT
Jul 24, 2014
I've search the web, and solved all the errors that appeared till I got a clean build. Now any time I run the code I run into this issue.
enter hour of mtime : 19
Mmin: 26
Msec: 05
standard time is 12:00:00 AM
military time is 00:00:00
I can't figure out why this isn't displaying any of my inputs.
#ifndef TIME_H
#define TIME_H
class Time {
public:
Time(int = 0, int = 0, int = 0);
~Time();
int hour; // valid values are 0 to 23
int minute; // valid values are 0 to 59
[Code] .....
View 2 Replies
View Related
Mar 3, 2015
This program is suppose to store input from a user (example 14 15 27) and output it three times. Once to confirm the input using the get function to recall the data, once to look like military time (14:15:27), and once to look like slandered time (2:15:27 p.m.).
The program runs, but this is what I'm getting:
I'm thinking its because I'm using the same integers to store two sets of data. I tried to create different integers for every set of data it didn't seem to fix the problem. The fact that the program is running makes trying to figure out where the problem quite confusing to say the least.
Code:
#include <iostream>
using namespace std;
class time {
private:
int hr, min, sec;
[Code] ....
View 6 Replies
View Related
Aug 7, 2014
I have a Class called 'DataManager' which contains a list of my 'DataItem' objects (this are created by an XML file).
I have also created some custom controls which, among other things, has a property to link it to a "DataItem" object.
My question is, is it possible to create an instance of my DataManager class at design time (which runs all the code as it would at run time to create all the DataItems from the XML)?
I want to do this so that I can update my DataItem property in my custom controls to use a UITypeEditor which then allows me to link to a DataItem at design time.
View 4 Replies
View Related
Mar 13, 2014
I am trying to create two classes: a Date class and a Time class. The Date class has to have three private data members: day, month and year. The Time class should have two private data members:hour and minute. Each class should have two member functions: a constructor and display. I am lost and my code won't run ....
class Date {
private:
int month, day, year;
public:
Date(int m, int d, int y){
month = m;
day = d;
year = y;
[code]....
View 2 Replies
View Related
Feb 18, 2015
I am creating a class called time and we've had to do operator overloading for <, > , <=, >=, ==, !=, ++, --, >>, <<, * , +, and -.
Well I have done and error checked them all. The only one I cannot seem to get right is the minus and its because of the error checking. I am having issues with times like this
t1 = 0:0:2:3
t2 = 0:0:1:4
t1 - t2 should equal 0:0:0:59 but it returns 0:0:1:-1.
(days:hours:minutes:seconds)
I need it to check for all cases and I just do not know how. Here is the code I have so far:
time operator- (const time& x, const time& y){
time subtract;
subtract.days = x.days - y.days;
subtract.hrs = x.hrs - y.hrs;
subtract.mins = x.mins - y.mins;
subtract.secs = x.secs - y.secs;
[Code] .....
View 1 Replies
View Related
Nov 29, 2014
Design, implement, and test a class that represents an amount of time in minutes and seconds. The class should provide a constructor that sets the time to a specified number of minutes and seconds. The default constructor should create an object for a time of zero minutes and zero seconds. The class should provide observers that return the minutes and the seconds separately, and an observer that returns the total time in seconds (minutes x 60 + seconds). Boolean comparison observers should be provided that test whether two times are equal, one time is greater than the other, or one time is less than the other. (You may use RelationType and function ComparedTo if you choose). A function should be provided that adds one time to another, and another function that subtracts one time from another. The class should not allow negative times (subtraction of more time than is currently stored should result in a time of 0:00). This class should be immutable.
this is one of my main errors: Error1error C2653: 'Time' : is not a class or namespace namec:userskdesktop
oane statecisp 1610visual studioschapter 12 assignmentchapter 12 assignmentchapter 12 assignment.cpp131Chapter 12 Assignment
//The implementation file ImplFileTimeClassAsgnt.cpp:
#include "Time.h"
#include <iostream>
using namespace std;
Time::Time() {
mins = 0;
secs = 0;
[Code] ....
View 2 Replies
View Related
Mar 10, 2015
This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??
#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;
[Code] ....
View 2 Replies
View Related
May 1, 2013
So I'm trying to learn how to use time for time based movement and what not. I did this only knowing the command time(&variable)
time_t timer;
int I, X;
void main() {
time(&timer);
X=timer;
while(I==5) {
[Code] ......
There's probably some other better way to do it... Obviously but for now I see it as putting current time in X.
start while
take in time constantly until I is 5
constantly asking is time>X(preset time 5 seconds ahead)
if it is
display message and add one to I
Why doesn't this display my message after 5 seconds?
View 1 Replies
View Related
Oct 21, 2013
I've been trying to calculate the Second standard deviation but the average in the second loop isn't calculating correctly which is causing the standard deviation (method 2) to not calculate correctly. I can't find anything wrong.
Code:
#include <iostream>#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
usingnamespacestd;
int main ()
[Code]...
View 8 Replies
View Related
Jul 11, 2014
I have a program that will calculate max, average, etc from a file of numbers. However, I cannot get it to calculate standard deviation.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cmath>
[code]....
View 4 Replies
View Related
Feb 6, 2014
How to make a standard deck of cards and being able to shuffle and distribute the cards. I have made an array to store each card and I can display them but I assigned them all in order according to the suit and rank. Is this a viable way to do it if I intend to have a shuffle effect? Or should I create an array, randomly generate card, check for duplicates, then put them in the array, then display the array? Each card is a structure with two void pointer members for suit and rank.
View 1 Replies
View Related
Jul 18, 2013
Is there any code I can use to determine my compiler version and which Standard It uses? I know the following code determine that my compiler followed ANSI But how about a version of that? ****My OS is now Ubuntu
Code:
#include <stdio.h>
int main(void){
printf("File :%s
", __FILE__ );
printf("ANSI :%d
", __STDC__ ); //return 1 if it follow ANSI but version?
return 0;
}
View 3 Replies
View Related
Dec 22, 2013
Is there any way to do date math using standard C libraries? I looked around in the time.h but didn't see what I needed.
What I need to do is be able to add a certain number of minutes to a date and have it give the current date/time. For example, add 15918765 minutes to 01/01/1980 00:00 and have it tell me 04/07/2010 4:45PM. I really don't want to write this myself or go platform-specific.
Does this exist somewhere or am I SOL?
View 13 Replies
View Related
Mar 21, 2013
Here's my code, it's for a poker hand evaluator
input:
'ad 2d 3d 4d 5d...
...4s 5s 6s 7s 8s'
I think it should go through all the 10 crads and disply the name of each card, but it seems to only do it for the second hand
Code:
include <stdio.h>
#include <ctype.h>
int main( void ) {
char inputtedhand[64];
int z=0, counter=0;
int index;
int i=0,m=0,n=0;
[Code].....
View 3 Replies
View Related
Nov 14, 2013
I'm looking to translate say the standard code for 4 which is 52 to the integer 4 is that possible with a build in function i C?
View 5 Replies
View Related
Oct 30, 2013
so i'm using scanf() this way
Code:
int i;
while (scanf("%i", &i))
printf("%i ", i);
printf("
done
");
i tried several combination of Ctrl+D and "Enter", it's not terminating, Ctrl+C just "cancels" the whole thing without printing "done", i'm running this on linux installed on a PC
View 9 Replies
View Related
Oct 23, 2013
The main point of the program is to calculate equations just like a standard calculator but I wanted to do it myself. I don't understand what the problem is right now but I've managed to create a program that asks for both values but somehow it doesn't want to ask for an operator (*, /, + etc). What's wrong with my code that the terminal skips the scanning part for the operator?
Code:
#include <stdio.h>
int main() {
int value1, value2, answer;
char operator;
[code]....
View 12 Replies
View Related
Apr 15, 2014
Just wondering if there was a standard way people add a version number to their c++ code? I can just define a variable or #define and write the version number to that, but wanted to know if there is a standard method people use?
View 1 Replies
View Related
Sep 2, 2013
This has never happened before but I imagine that I've somehow accidently disabled a library or such.
namespace SB{
namespace Data{
class DLL Filed abstract{
//DLL is a macro defined as either __declspec(dllexport) or __declspec(dllimport)
//depending on whether this is open as a project or a header
[Code]....
The error is from intellisense and is present on every occurrence of std::string
View 14 Replies
View Related
Mar 21, 2014
Here's my attempt:
input.open(name);
if (input.fail()){
cout <<"Error opening file"<<endl;
}
while (input>>numbers)
{
counter++;
total += numbers;
[Code]...
Copy of the output:
Error opening file
The Standard Deviation of all the numbers is: -9.25596e+061
Press any key to continue . . .
Its not giving me the right answer.
View 1 Replies
View Related
Oct 7, 2014
Earlier 4-5 years back, When I started learning C++ I used textcolor() function to change the textcolour. But its not working in Code Blocks 13.12. Is there any other standard way to color the text and background.
View 2 Replies
View Related
Mar 15, 2014
Unable to compute Standard Deviation
View 1 Replies
View Related
Feb 1, 2015
The program does compile the average and the mean correctly. I can't understand why the standard_deviation member function isn't applying the sqrt properly:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const int N = 10;
class Standard_Deviation {
[Code] ....
View 7 Replies
View Related
Mar 5, 2014
So I'm working on an assignment that is roughly about implementing the grep utility, only it has to be programmed in C. The weird nuance of the assignment is that while we are implementing the utility, we can use grep only we cannot pass grep a filename to search through(we are supposed to pipe a line from the file to standard input so that grep can examine it there.) Anyways, when I reach execlp, it will print out what is in stdin from the terminal, but it hangs at that point and I have to press Ctrl+Z to exit. I probably have the most difficulty with using this function, so I came up with a smaller scale model to get the basics down. Anyways, here's my code:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char* argv[]){
[Code] ....
View 10 Replies
View Related
Mar 18, 2015
I have an HTTP/1.0 webserver that I'm building in C that needs to exhibit CGI script functionality. Specifically, what I'm having trouble with is that I have two processes: process 1 is the webserver, process 2 is the CGI script. I fork in the webserver, and then call exec to run the CGI script (specifically, I used execv()). I've read from the CGI specifications in the RFC that in the case of a webserver receiving a POST request, the CGI script should read the arguments for the POST request from stdin. However, when I write to stdin, it simply echoes what was written to the terminal window and when the CGI script tries to read from stdin, it blocks.
So, with all that said, I'm pretty sure there is some simple conceptual explanation to my problem, but I can't figure it out. Do I need to use pipes or some form of interprocess communication to send the data from the webserver to the CGI script, or can it just be done with stdin (and possible stdout)?
View 2 Replies
View Related