C/C++ :: Given Person Birth-date Or Any Other Date Will Display Day Of Week

Oct 11, 2012

i'm making a program that, given a person's birthdate or any other date, will display the day of the week of the person was born.

There is this part where it says "use a switch statement to make this calculation, If desired month is 12, add the number of days for November, if desired month is 11 add the number of days for october....

So it's suppose to start with "case 12 :...

I can't figure out what to write for the statement....

View 6 Replies


ADVERTISEMENT

C :: Calculation Birth Date As Floating Number

Sep 25, 2014

i want to calculate age of a person so then i try to make an algorithm which is used in a function like (i know to use math.h for abs()) double age_calculator( int year, int month, int day);

Code:

double age_calculator( int year, int month, int day);
// p means present(current)
int pyear=(2014-year)*365;
int pmonth=(abs(9-month))*30;
int pday=abs(25-day);
return (pyear+pmonth+pday)/365.0;

how can i use current date, i mean i want to use date of present day instead of 2014,25 and 9. I don't know how i can use date of every day.For instance my function returns 14.74 for the parameters; 2000, 01, 01 (for the current day 25/09/2014)

View 6 Replies View Related

C++ :: Create A Program Which Prompts For User Input Of Current And Birth Date

Sep 27, 2014

I have an assignment in which i must create a program which prompts for user input of current and birth date, which will compare said dates and output if its your birthday or not. I've completed a large portion of it, but cannot figure out how to get the user input of month as an integer such a 2 into February.

#include <iostream>
using namespace std;
class DayOfYear {
public:
void input();

[code]....

View 1 Replies View Related

C++ :: Input Date And Get Day Of The Week

Oct 23, 2014

How can I check for an invalid date when I run the program? I am trying to enter a conditional statement that checks for a valid or invalid date.

Programing Question: Write a program that inputs a date (e.g., July 4, 2008) and outputs the day of the week that corresponds to that date. Here is what I Have. The program runs. I need it to loop around.

#include <iostream>
using namespace std;
const int JANUARY = 1;
const int FEBRUARY = 2;
const int MARCH = 3;
const int APRIL = 4;

[Code] ....

View 1 Replies View Related

C++ :: Input Date - Output Day Of The Week

Apr 3, 2013

I'm just starting coding and I just want it to input a date, then output a day of the week.

Code:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int startday = 0, sm = 1, sd = 1, sy = 2000, cm = 0, cd = 0, cy = 0;
cout << "Please enter the current month, day, and year: ";

[Code] ....

View 1 Replies View Related

C++ :: Two Date Structures Sharing Same Date

Mar 28, 2014

I have two date/time structures which I'm populating, but when I populate the second one it sets the same values in the first. This is what I've got so far

tm *FirstDate = gmtime(&now);
tm *SecondDate = gmtime(&now);

cout <<"Enter your first date in the format dd/mm/yyyy" << endl <<">";
getline (cin,tempstring);

[Code] .....

View 2 Replies View Related

C/C++ :: How To Get System Date And Time And Display It

Mar 16, 2012

How to get system Date and Time and display it in the format DD/MM/YYYY ??

View 2 Replies View Related

C/C++ :: Display Unique Date And Its Related Price Found In Txt File

Apr 23, 2015

Currently i have a system that will store user input into a txt file, and have a function that will compute the daily sales of the month(Check by system date month) and display the sales of the day and the grand total of that month.

Take for example, the system date now check that the current month is Apr. Below are my current output:

20Apr2015 $11.5
20Apr2015 $15.5
22Apr2015 $4.5
25Apr2015 $4.5
28Apr2015 $4.5
20Apr2015 $4.5
Grand Total $45

But my desired result should be as below

20Apr2015 $31.5
22Apr2015 $4.5
25Apr2015 $4.5
28Apr2015 $4.5
Grand Total $45

Textfile data:

1|Bag|2|3|6|20Apr2015
2|Fruit|2.3|5|11.5|20Apr2015
3|Fruit|2.3|5|15.5|20Apr2015
4|Water|0.9|5|4.5|22Apr2015
5|Water|0.9|5|4.5|25Apr2015
6|Water|0.9|5|4.5|20Jul2015
7|Water|0.9|5|4.5|20Jul2015
8|Water|0.9|5|4.5|28Apr2015
9|Water|0.9|5|4.5|20Apr2015

Below are my code.

struct TransactionPile {
// to record item information.
string itemid;
string itemdesc;
float unitprice;
int quantity;
float totalprice;
string date;

[Code] ....

View 6 Replies View Related

C Sharp :: How To Display Date Range In Crystal Report In Windows From

Feb 18, 2013

how to display date reange in crysta report , i have table contains :

id score date name
1 30 2-10-2012 x
2 40 3-10-2013 y
3 40 3-7-2009 z
1 45 5-10-2013 x
1 50 4-10-2009 x

ouput report:

id:1 name :x

2009-10| 2012-2013
50 30
40

View 2 Replies View Related

C :: Display Current Time And Date In Program And Use Variable To Store Each Of Values

Feb 16, 2013

i need to display the current time and date in my program and use variable to store each of the time values like

a = 10
b = 29
c = 31

printf(``%d : %d : %d``, a,b,c);

which then give the output as - 10:29:31

How to save the time in variables in C....

i am using C in windows 7 and my complier is Bloodshed Dev C++

View 7 Replies View Related

C++ :: How To Validate Date

Jul 14, 2013

How would I validate the date?

struct Inventory {
char SKU[SKU_SIZE];
char category[CAT_SIZE];
int qty;
double cost;
char date[CAT_SIZE];

[Code] .....

View 4 Replies View Related

C :: Enter Date - Calculating Next Day

Mar 14, 2013

Currently I am working on a program where you enter in a date 14 03 2013 (Day, Month, Year) and you get the next day. I seem to be coming stuck with months with less than 31 days, and the whole leap year thing. Here is my code so far.

Code:
#include <stdio.h>
int day, month, year, next_day, next_month, next_year, calculation;
int main() {
printf("Enter a date in the form day/month/year: ");
scanf("%d %d %d", &day, &month, &year);

[Code] .....

View 4 Replies View Related

C :: Data Type For Date

May 18, 2014

If I am asked to declare a data type for Date which should be in the format DD/MM/YY, which data type should i use for it? Is there any data type known as Date in C?

View 2 Replies View Related

C++ :: Input Validation For Date?

Jul 19, 2013

How do you do the input validation for date? I used:

char rec.date[SIZE];
cout<<"date"<<endl;
cin.getline(date,SIZE);

I want the user to write in this format (mm/dd/yy)

View 3 Replies View Related

C++ :: Reading Date From File

Mar 21, 2014

So here's my file content:

J001 Graham Bell 145 20/03/2012 23/03/2012

my current code is.

#include<iostream>
#include<fstream>
#include<string>

[Code]....

I have 2 problems right here.

1) Why it could not load or read my file.When i run the codes.I was prompted with a blank cmd instead of "File could not be located.

2) How do I calculate how many days that a customer been staying inside the hotel?

For example:20/03/2012-23/03/2012

View 1 Replies View Related

C++ :: Converting String To Date

Apr 27, 2014

Quick code for converting strings to Dates in C++.

Example: What is the date:
User response: 12/05/14

Any way I can code this to recognize it as a date, and make it so that the date is sortable? Not referring to the system date, but a user input date.

View 4 Replies View Related

C++ :: Date And Time As A String?

Aug 28, 2014

This is what I have:

#include <ctime>
#include <string>
using namespace std;
void date_and_time(string &date, string &time){
time_t current_time;

[Code] ......

Is there a way to make sure that the strings would not contain trailing spaces?

View 1 Replies View Related

C++ :: How To Delete Date On A Txt File

May 7, 2014

I'm doing a daily time record that record every inputed date on a txt file how will have an option or how will I delete a some of the choosen date? i'm using C++

View 1 Replies View Related

C/C++ :: Converting String To Date?

Mar 19, 2012

how to convert from string to date in c++? Example: 17 mar 2012 to 17/03/2012

View 1 Replies View Related

C++ :: Getting User Input In Date Format

Oct 26, 2014

So I have a programming assignment which is for getting a user input in the format of m/d/yyyy. This is stored as d/m/yyyy. I have been able to code all the rest of the requirements of the program but the thing that is giving me trouble is this. The year is allowed to go from 1-3000. The format of the displayed date is:

a zero-filled, two-digit day number, a dash, full name of month, a dash, zero-filled, four-digit year.

I am able to use a switch statement in order to get my name of the month. What I am struggling to figure out is the whole zero filled two digit day and zero filled four digit year. From the way the input is store it appears to me that it will be stored as yyyy which means if you were to enter 0001 for year 1 then it should output it as that (this is an assumption based on format). What I don't get is that the day is entered and stored as d which means if you put in 12 how would it be stored. However if you put in 6 to print the output I would need to add a zero and I dont know how to do that either.

Here is the code for getting the input. The function must stay formated this way as per the instructor. The / is stored but ignored hence the char for second and fourth since / is a char

Code:
void getDate (int& day, int& month, int& year){
char second;
char fourth;
cout << "Please enter a date in the format of m/d/yyyy" << endl;
cin >> month >> second >> day >>fourth >> year;
}

View 4 Replies View Related

C :: Date Math Using Standard Libraries?

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

C++ :: Input Date Field In A Comment

Mar 11, 2014

I am building a template for CodeBlocks, which pre-write some includes, the main skull and a header.

This header looks like that :
/**
* @Author Me
* @Description Brief description
* @Date ??
*/

I would like to put the current Date, just after the line @Date, is-it possible ? And if yes, it-is possible to put a field @FileName which copy the filename into the comment ?

View 2 Replies View Related

C++ :: Adding Current Date To The End Of A String

Dec 12, 2014

I need to add the current date to the end of a string but I only need to add the day and not the year or month.

Put the code This is what i have

char date[9];
_strdate(date);
cout << date << endl;

View 1 Replies View Related

C++ :: Converting Date To Roman Numerals

Feb 26, 2014

Program to convert a date entered into roman numerals. I can only use one output prompt to get the date, so that makes it more difficult. Here is what i have, but how to go about the rest of it.

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int array_date[20];
char I; // one

[Code] .....

View 1 Replies View Related

C# :: How To Write If Statement With Specific Date

Jun 2, 2014

Writing an if statement where the date has to be greater then 1/1/1880?

class Movie {
private DateTime m_ReleaseDate = DateTime.MinValue;
public DateTime ReleaseDate {
get { return m_ReleaseDate; }
set {
if (value > DateTime.FromOADate("1/1/1880")) {
m_ReleaseDate = value;
} } } }

View 1 Replies View Related

C# :: How To Retrieve Only Date From Datetime From Database

Nov 25, 2014

i have a form in which i have a field date of birth , and a textbox to fill date of birth , when a person fills his date of birth like 01/01/1990 , then it will be saved into database , and when i retrieve this date form database then this comes 01/01/1990 12:00 AM , i want only date part from it.

This is my form to fillup date of birth

form.aspx
<tr>
<td width="30%">
Date of Birth
<br />
</td> <td style="width: 1px">
:<asp:TextBox ID="txtDateofBirth" runat="server" placeholder="dd/mm/yyyy"></asp:TextBox>
</td> <td class="td2">
</td>
</tr>

this is code for form.aspx.cs

SqlCommand cmd = new SqlCommand("insert into ApplicantForm(NameofApplicant, dateofbirth)" +
"values( @NameofApplicant, convert(Datetime, @dateofBirth, 103)", con);
cmd.Parameters.AddWithValue("@dateofBirth",txtDateofBirth.Text);

this is code for print of this date of birth

print.aspx

<asp:Label ID="txtDOB" runat="server" ></asp:Label>

this is code print.aspx.cs

SqlCommand cmd = new SqlCommand("Select * from ApplicantForm Where ApplicantId=" + ((Request.QueryString["ApplicantId"])) + "", con);
dr = cmd.ExecuteReader();
txtDOB.Text = dr["dob"].ToString();

View 2 Replies View Related







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