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


ADVERTISEMENT

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

C++ :: Calculate Approximate Age Of User Based On Current Date And Their Birthday

Nov 23, 2012

I have an extra credit project where I'm supposed to calculate an approximate the user's age based on the current date and their birthday. My problem is that I am not getting the proper date and time. C++ keeps giving me some random date. I looked up c++ time format on the internet because this is extra credit and not in my book.

I am currently using dev C++ 4.9.9.2. Here is my current code :

// included libraries
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <time.h>
#define cls system("cls")
#define pauseOutput system("pause")
void printM(int x);
void age(int m, int d, int y, int &yearAge, int &monthAge, int &dayAge);

[Code] ....

View 1 Replies View Related

C++ :: Program Which Takes Date And Time Input From The User

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

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 :: 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++ :: Program That Prompts User For Int Value?

Sep 23, 2013

I'm making a program that prompts a user for an int value. The value input by the user must be a multiple of 16. If it is not, I must return an error message.

View 5 Replies View Related

C++ :: Program That Prompts User To Specify People And Cars

Feb 10, 2014

Implement a class Person with two fields name and age, and a class Car with three fields:

The model
A pointer to the owner (a Person*)
A pointer to the driver (also a Person*)

Write a program that prompts the user to specify people and cars. Store them in a vector<Person*> and a vector<Car*>. Traverse the vector of Person objects and increment their ages by one year. Traverse the vector of cars and print out the car model, owner’s name and age, and driver’s name and age.

#include <iostream>
#include <vector>
#include <conio.h>
#include <string>

using namespace std;
class Person {

[Code] ....

View 7 Replies View Related

C++ :: Program Prompts User To Select A Number Between 2 And 12 Twice?

Oct 8, 2014

Here is the whole code:

#include <iostream>
#include <ctime>
#include <cstdlib>
//This program prompts the user to select a number between 2 and 12
//computer throws two dices
//player win if selected number matches the sum of the two dices thrown by computer

[Code] .....

View 6 Replies View Related

C++ :: Program That Prompts User For 10 Grades And Then Find Average

Feb 24, 2015

I need to write a program that prompts the user for 10 grades and then find the average. I have that part but I need to average to not include -1. How can I tell the program to not calculate -1 into the average.

#include <iostream>
using namespace std;
int main() {
//Declare variables
float grade[10]; // 10 array slots
int count;
float total = 0;
double average;

[code].....

View 1 Replies View Related

C++ :: Write A Program That Prompts The User To Enter Integer?

Nov 8, 2013

Write a program that prompts the user to enter an integer and then displays that integer as a product of its primes and if it is a prime then it should say so? Above is the question I have been given

#include <iostream>
#include <vector>
using namespace std;
int main () {
int num, result;
cout << "Enter A Number " << endl;
system ("pause");
return 0;
}

This is what I have so far, do I have to use a for loop, a while loop or a do loop,

View 7 Replies View Related

C++ :: Write Program That Prompts User To Enter Item Number

Jun 27, 2013

Write a program that prompts the user to enter an item#, the program should determine if the item is in the file and print the price of the corresponding item. If the item is not in the file an error message should be printed.

All I have so far is

string item_no=0;
cout<<"Enter a item#";
getline(cin,item_no);
if stream openData;

I need to finish the rest in pseudo code

View 2 Replies View Related

C++ :: Create A Program That Will Prompt The User For Input?

Dec 28, 2014

I need to create a program that will prompt the user for an input, then it will save their input to a file and then it will prompt the user to input "Open" and then the file containing their first input, will open up and show their input.

View 19 Replies View Related

C++ :: Create A Program That Will Let User Input Amount In Form?

Jan 4, 2014

Figure this out using [TURBO C]

Create a program that will let the user input an amount in the form (367). The Program should determine the no. of coins for each dominations : 50,25,10,5,1. (using Turbo C)

View 7 Replies View Related

C++ :: Create Program That Has User Input 5 Digit Number?

Mar 9, 2013

Im trying to create a program that has the user input a 5 digit number. If it's between 10000 & 99999, it will do one thing..(just saying 'yes' for now. Outside those numbers will prompt the user to input again. However, if the user inputs the exact digits 76087, it should display 'term'.

This current code is displaying 'term' whenever the user inputs the 5 digits.

Code:

#include <iostream>
using namespace std;
int main() {
int pin;
cout << "Welcome to Movie Food
Enter your 5-digit pin code: " ;

[code]....

View 14 Replies View Related

C/C++ :: Create A Program That Prints A Certain Number Of Asterisks Based On User Input

Apr 12, 2015

I need to create a program that prints a certain number of asterisks based on user input. The user inputs 5 and I want my program to output "*****". How would I do this in C? I've tried printf("%#**", myvariable) but this does not work it only prints "*".

View 1 Replies View Related

C :: Create A Program That Asks User To Input Integer Lengths Of Three Sides Of A Triangle

Sep 6, 2013

C programming: I want to creat a program that asks the user to input the integer lengths of three sides of a triangle, and if so whether the triangle is a right-angled, acute or obtuse one. i am having some doubts about the if, else if statements. I never seem to know how and in what order to use them.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[]){
int SideA;
int SideB;
int SideC;
}

[code]....

View 14 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++ :: 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++ :: School Project - Getting Current Date And Time

Dec 30, 2014

I am doing a school project. The project basically is that it records the in and out time of an employee(of an particular company).The employee while checking in or out should enter a unique key generated specially for him so that no one else can check in and out for him.Then referring to the employees position( A worker or a manager or something like that) his total working time each day , for a week and a month is calculated. The company starts at 8 am and ends at 5 pm for 1st shift and for second shift from 3.30 pm to 2.30 am. Plus Saturday and Sunday off. Then after a month the program refers to the working time date stored in a file and calculates his pay(For workers its per hour salary and for managers it aint).

If an employee is consistently late the details are forwarded to the HR account( so that necessary steps are taken).This will support the company log the details of their employees duty time plus give enough detail to take action if someones always late. I'm doing this as a school project and it needn't be of enterprise class and all.. But i want the coding to perform as it should. Also i'm forced to use the old Turbo C++. Now i'm struck in the place where the time of the employees in and out time is logged. This coding does the work

Code:
void main( ) {
clrscr();
char dateStr [9],timeStr [9];
_strdate( dateStr);
cout<<" The current date is "<<dateStr<<'

[Code] ....

I think the second one is better as it not only gives me date but also gives me the day so i can check easily for the weekends. So, how these time functions work.

View 1 Replies View Related

C/C++ :: Assigning Current Date To Integer Values

Sep 26, 2014

How can i assign current date as integer ?

for example:

today's date 26 Sep 2014 on a computer
i try to make as below
int day=26
int moth=9
int year=2014

I also research i think i will use time.h library surely

View 3 Replies View Related

C/C++ :: Save The Current Date And Time Into A Char Array?

Jan 14, 2015

I am trying to use to save the current date and time into a char array using this code:

char current_time(char *date){
time_t result = time(NULL);
date = ctime(&result);
return *date;
}
main{

[Code]...

now when I output the date char array into a txt file I only get gibberish.

View 6 Replies View Related

C :: Program To Take Time And Date Typed By User And Increase It By 1 Minute

Mar 22, 2013

I'm having a problem with my homework. The task is to write a program that will take time and date typed by user, and increase it by 1 minute. I should write 3 functions - first calls second function that updates time and calls third function, if time is 00:00.Time update works, but date update does not.My whole written code:

Code:

#include<stdio.h>
struct DateAndTime {
struct date {
int day;
int month;
int year;

[code]....

I should check if inputs are numbers only, so I tried including isdigit function from ctype.h library, but that didn't work either, after I was trying it for a good hour or so, but I kinda rage quit that...

View 8 Replies View Related

C++ :: Using While Loops That Prompts User For A Set Of Integers

Jan 30, 2015

-Write a program using while loops that prompts the user for a set of integers.

-Your program will ask for one integer at a time. If the number 0 is entered, the list is complete and your program will output two results: the sum of the even integers and the sum of the odd integers.

-After each integer is entered by the user, your program will print out whether the integer entered by the user is less than, equal to, or greater than the previous integer. Assume for the first integer entered by the user that the “previous integer” was 0.

-Your program must handle a variable number of inputs (in other words, you cannot hard code for the test cases).

This is what I have so far:

#include <iostream>
using namespace std;
int main() {
int a;
int b;

[Code] .....

View 2 Replies View Related

C++ :: Compiler Skipping User Prompts?

Mar 24, 2014

the problem that I'm running into is that the compiler skips to the end when I put my initials in //User input > "Initials"

I'm using Microsoft Visual C++ 2010 Express.

Here is the assignment:

Plan and code a program to do the following. You found an exciting summer job for 5 weeks. It pays $15.50 per hour. You will input the number of hours per week that you worked and then compute your total earnings. You must pay taxes of 14%. After paying taxes, you will spend 20% of your money on cloths and 5% on school supplies. After buying clothes and supplies, you will use 25% of the remaining money for savings.

Input

Your 3 initials and the hours for each of the 5 weeks. Use the following numbers of hours for your first test 25, 30, 20, 23, 22.

Calculations

Gross pay is the rate of pay times the sum of all hours you worked. Use CONSTANTS for each of the following rates:

Tax rate 14% of the gross earnings
Clothing 20% of earnings after taxes
School supplies 5% of earnings after taxes
Savings 25% of earnings after taxes and expenses

Output:

Output your initials, total hours worked, gross earnings, taxes, net earnings after taxes, clothing expense, supplies expense, amount going to savings and amount left to spend. Output must be aligned to the right as shown with 2 decimals in all numbers. Sample output:

Initials ABC
Total Hours Worked 120.00
Gross Earnings 1860

Taxes paid 260.40
Net Earnings 1599.60

[code]....

Turn in:Be sure your output file contains user prompts and what was entered by the user. In addition to the results of your program processing. Run with above listed data.

Here is my code

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double Initials, TotalHours, GrossEarn, TaxesPaid;

[code]....

View 6 Replies View Related

C++ :: Write Program That Uses Boost Library To Input String Date?

Apr 23, 2014

I'm trying to write a program that uses the Boost library to input a string date in the format mm/dd/year and outputs to the string its corresponding day of the week. I wrote the program that I thought would accomplish this, but it doesn't seem to work. Below is the code I wrote:

#include <string>
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"

[Code]....

When I compile this using codeblocks it gives me the error "In function `ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtRKSs':|
C:Users
osaDesktop est3........Liboost_1_55_0oostdate_timedate_parsing.hpp|67|undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()'". And it takes me to the file date_parsing.hpp and highlights line 67. I don't understand why this isn't working.

View 3 Replies View Related







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