C++ :: Military And Standard Time Program Not Displaying Inputs
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
ADVERTISEMENT
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
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
Mar 2, 2013
I want to create a GUI using C, for displaying time when a time zone is selected.
I absolutely don't know how to write a program for that. How to get the time of a zone displayed when the zone name is given as input.
View 2 Replies
View Related
Oct 4, 2013
I want to take the standard output of a shell command (in Red Hat, using tcsh, in my case) and redirect it into my program for processing.
(Then ideally I would love to take the output of my program and redirect it to yet another command, but this is a second issue.) Simple example: I naively thought this might work:
I want to type this on the shell:
Code: $ echo Harry > hello and I was expecting this output on my terminal:
Code: $ hello, Harry And this would be my simple hello program:
Code: #include <iostream>
#include <string>
int main() {
std::string usrInput;
std::cin >> usrInput;
std::cout << "hello, " << usrInput << std::endl;
return 0;
}
View 3 Replies
View Related
Jun 30, 2014
A program that asks 10 positive integers and classify them as odd or even positive integer inputs. The algorithm has to trap negative integer inputs. The output will be displayed in two columns. ODD and EVEN.
here's my program code...
#include<iostream>
using namespace std;
main() {
int countA;
for(countA=0;countA<=10;countA++) {
[Code] ....
View 3 Replies
View Related
Feb 17, 2013
I want to create a grading program that the user inputs a name and then on that value (name) there is a vector of doubles to represent his/her mark and then calculates an average how would I go about doing this?
View 1 Replies
View Related
Apr 10, 2014
How do I write a program that'll interpret "M" and "F" inputs and print a "you're a guy" or "you're a gurl" message?
Code:
#include <stdio.h>
#include <conio.h>
char gender;
char main(void) {
printf("type M or F
[Code] ....
View 5 Replies
View Related
Feb 7, 2015
I am writing a program that deals with 2d arrays. The program inputs the number of rows and columns and asks for the entries. When the program run and compiles it works perfectly until it outputs then it gives me a warning.
Here is my code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int row1=0,col1=0,i,j;
//int a[row1][col1];
int** a= new int*[row1];
[Code]...
I am learning how to do this before I can move on so it can read a text file of numbers.
Also I am having problems with ////delete [] a[];///// I took it out because it made my code compile and run but when I add it in, it gives me an error:
matrixtesting.cpp|56|error: expected primary-expression before ']' token|
I know this expression is suppose to deallocate the array.
View 7 Replies
View Related
Sep 30, 2013
For class I need to write a program that inputs a file (the dividend), performs binary division on the file (using 0x12 as the divisor), and outputs the remainder(checksum).
I have researched binary division algorithms and I get the general gist, but I'm still unsure where to start. How would I store the dividend and divisor? As two arrays of bits?
Then, I need to figure out how to perform shifts and XORs on the the binary numbers. Maybe I should use bitwise operations?
View 5 Replies
View Related
Apr 9, 2013
I have a Windows form application which has database and will store user details. my problem is while executing program form is not displaying .
View 1 Replies
View Related
Apr 27, 2013
I have written a MFC dll to interact with an API and it is run by the target program. the first 100 bars are drawn properly but then the program ceases to operate. I am guessing I have a memory leak but I probably just dont understand what I am doing as I am quite new to programming MFC GDI. Here is my code that causes the trouble...
The variables coming in are commented out to facilitate testing and so it would be displaying the same bars over and over because of this. it worrks for 100 bars, then crashes.
void MainDlg::SS_UpdateChart() {
// the chart plot is completely recalculated each time a new bar is shown
// 300 is plottable height
// 400 is plottable width, 39 bars
int displayChartHeight = 300;
[Code] .....
View 11 Replies
View Related
Jan 29, 2014
I would like to understand a function on strings. Below is a code that I took from my teacher where the user inputs a string and prints out the length of the string.
Code:
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int i = 0;
[Code] ....
Now I understand that it returns the count in "int" so my question is:
Let's say i declared
Code: int count = 0;
at the beginning of the code and then made
Code: count = strlen(str);
why wouldn't i have the same result? Is there a way to do it also?
View 7 Replies
View Related
Mar 26, 2013
I've written a program to read inputs in a text file. The file named Input.txt contain integers 2 3 and 4. My program is as follows:
#include<iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
int main (){
int x,y,z;
[Code] ....
the program is outputing x=2293616 , y=0 and z=0 instead of x=2, y=3 and z=4.
View 9 Replies
View Related
Nov 6, 2014
i writing a code which will calculate the difference between time_in and time out. Can i use a 2 dimensional array for example
int time_in[hours][minutes]
int time_out[hours[minutes]
View 3 Replies
View Related
Jan 20, 2014
I am an IT college student and this is a self-assigned project i have done in an attempt to learn programming in C AND at the same time how time scheduling of an OS works (Both done in order to prepare for upcoming semester exams) using FCFS ,SJF, RR and PS algorithms (planning on adding SRT too sometime soon). (took me 9 hours total work time including validations). What i wanna know is from more seasoned coders if i am on the right track. *cross fingers*
Code:
#include <stdio.h>
#include <stdlib.h>
#define P_Q 1000
int main(int argc, char *argv[])
{
float min_value,
}
[code]....
View 11 Replies
View Related
Feb 14, 2013
I'm trying to display the AM/PM on my program:
Also is there a way to display the time only instead of the date? How will i change the program to display the time in standard 12 hours, instead of 24 hours?
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t tim;
time(&tim);
cout << ctime(&tim);
}
View 1 Replies
View Related
Jul 4, 2013
I'm challenged to write a program which calculates the time difference between two daytime.
compiler doesn't give an error, yet the warning: "format '%d' expects argument of type 'int *', but argument 3 has type 'int' [- Wformat]" for lines 24 and 26
However, by entering the first time the program crashes anyway. so I assume I do really need some pointer to make it read from the console can you see where my problem is?
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int Second;
int Minute;
int Hour;
}Time;
[Code]...
View 4 Replies
View Related
Feb 26, 2013
I have a weird problem, my computer restarts imidiately after program writen in dev-cpp is compiled AND run. When I run any program, it lasts about 1 second, then program closes, and computer reboots. It doesn't matter whether program is writen now or earlier, my dev-cpp version is 4.9.9.2. Source code can be as simple as this:
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
getch();
return 0;
}
and it restarts anyway...
View 2 Replies
View Related
Mar 9, 2013
Say I want to leave a program running and it stops when I press F9 for instance, I'm looking for something like (and note this is just a generalization).
#include blah
using namespace std;
/wait 2 hours
/key.press = F9
return 0;
View 5 Replies
View Related
Dec 16, 2013
I am trying to create a program that calculates fraction of time remaining when a student leaves during the middle of the semester. I have to use function files here. I am having trouble with the division in function long double tuitionfrac(int, int, int). No matter what numbers are entered, fractime gives an output of 0. I don't understand that.
long double tuitionfrac(int opening, int leaving, int semend)
{
int lefttime = semend - leaving;
cout << "Left time " << lefttime << endl; //for error checking
int tottime = semend - opening + 1;
cout << "Total time " << tottime << endl;
long double fractime = lefttime/tottime;
cout << "fractional time " << fractime << endl; //always returns as 0.
return fractime;
}
View 4 Replies
View Related
Apr 7, 2013
I want to know if there is a function or library that starts counting time when the program starts. Because I'm making a program that is dependent on time.
Pseudo code
time starts
if ( seconds % 2 == 0 ) {
counter++;
}
View 2 Replies
View Related
Oct 13, 2014
We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.
View 11 Replies
View Related
Apr 23, 2014
how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...
View 4 Replies
View Related
Jan 20, 2013
I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:
struct time
{
short year;
short month;
short day;
short hour;
short min;
};
My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.
I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.
View 2 Replies
View Related
Mar 5, 2013
I have to make a 8-puzzle and I got the algorithm i just dont know how to restart the program every time i type the move of the blank place in the 3x3 puzzle so i dont have to make 10000 lines to solve the puzzle
View 2 Replies
View Related