C/C++ :: Printing The Day Of The Week?

Feb 3, 2014

I am writing a program that takes the Month, Day, and Year inputted from the user and outputs the day of the week (Ex. "February 2, 2014 falls on a Sunday"). I got it to print out the date but I can't figure out how to output the day. Would I be using the ctime function?

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

[Code].....

View 1 Replies


ADVERTISEMENT

C++ :: Get Day From Week Program

Oct 25, 2014

My program is supposed to get ask the user a date (MM DD YYYY) and its supposed to tell them what day of the week that specific date is. Well, I was told to check for leap years, and if the Feb 29 is a non-leap year, its supposed to cout an invalid statement and tells the user to try again. My problem is that its not looping through only when its Feb 29 2015 for example.I have been trying to find a solution and I cant find one so far? Like, I said, it works for other dates, just not checking and looping Feb 29 2014 or 2015, etc?

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

[code].....

View 2 Replies View Related

C++ :: Displaying Most Profitable Day Of Week

May 9, 2014

I am trying write a void function which will tally up the totals for each day and then display the most profitable day of the week.

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <fstream>
struct Menu_Items {
string Item;
double Price;

[Code] .....

The void function must pass as a parameter a pointer to the first element of the Orders_Placed array. I have attempted to write this. But I do not think I am even close. I need to have 7 double variables that hold the totals for each day of the week. Those are the MonTotals , TueTotals , etc....

How do I get these totals for each day?

How do I fix this void function so that is displays the most profitable day. Also, would the function call be Biggest_Profit(Orders_Placed)??

The GetPrice function provides the price given a menu item.

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++ :: 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++ :: Return Day Of Week Using Time Structures

Jul 9, 2014

I have a fun question that is an end of an inherited class. I am trying to return the day of the week using time structures. However, I cannot get the correct date from two different structures, even if they are declared as different structures. So, when I check the number of the week, the two provided to check with are the same.

point is: They keep coming up as the same.
bool Weekly::occurs_on(int year, int month, int day) {
struct tm * chec ;
time_t clock1 ;
time(&clock1);

[code]....

View 2 Replies View Related

C++ :: Write A Program That Tells The Day Of The Week?

Feb 7, 2015

I need to write a program that tells the day of the week, month, day, year, and whether it is a leap year or not from a input of MM DD YYYY form.

Example: Enter numeric values for month, day and year of a date> 10 31 1990 Wednesday, October 31, 1990 occurred in a non-leap year.

View 3 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 :: Take Averages Of Whole Week And Output Print Statement

Jul 17, 2013

I wanted to take the averages of the whole week and output a print statement. I've tired few ways this like assigning "temp" a pointer, or in each if statement assigning temp to a new variable like a, b , c etc. Then adding them all up at the end and dividing by 7. My issue is I am unclear how to store the number typed for each if statement while the program is running, then have it compute the simple equation. The code in question is below:

Code:
#include <stdio.h>
int main(int argc, const char * argv[]) {

int i, j = 0, temp = 0;
for (i=1; i<=7; i++) {
j++;

[Code] ....

View 1 Replies View Related

C++ :: Class DayType That Implements Day Of Week In A Program

Aug 15, 2013

Write the definition of the class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sunday for Sunday. The program should be able to perform the following operations on an object of type dayType:

a. Set the day
b. Print the day
c. Return the day
d. Return the next day
e. Return the previous day
f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.
g. Add the appropriate constructors

Write the definitions of the functions to implement the operations for the class dayType.

My code:

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string my_Day[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
class dayType

[Code] .....

And here are the error messages that I get:

Line 23 error: prototype for 'void dayType::setDay(int)' does not match any in class 'dayType'
Line 11 error: candidate is: void dayType::setDay()
Line 36 error: prototype for 'void dayType::getDay(int) const' does not match any in class 'dayType'
Line 13 error: candidate is: void dayType::getDay()

I know this is probably a really easy mistake but I am new to Programming and I have changed this code for days to no avail.

View 2 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++ :: Generate Calendar For A Year - Day Of Week Month Starts From

Oct 18, 2013

So for my C++ class I am required to create a program that will "Write a program to generate a calendar for a year. The program should accept the year and the day of the week for january 1 of that year (0=Sunday, 1=Monday, etc.)" (problem statement) and I am completely stuck. I've posted what I have so far below:

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

bool isLeapYear(int year);
int daysInMonth(int month, bool lpYear);
int printCalendar(int month);
int printDay(int dow);

[Code] .....

View 3 Replies View Related

C/C++ :: Compare Time Fetched From Two Week Number Of Different Year?

Jul 5, 2012

How to compare the time fetched from two week number of different year using C,C++.

I have used a naming convention for the files generated in a linux system. The naming convention will have the week number and date's day indication like Monday means M. I need to compare the two files of same week but on different years and calculate the time?

View 1 Replies View Related

C :: Take Integer Input For Temperature And Display Message For Different Ranges For Each Day Of Week

Apr 20, 2014

I'm writing the program below to take an integer input for temperature and display a cheesy message for different ranges for each day of the week.

I tried using two if statements, the first to determine if the input is valid, and the else display that it was invalid and to try again.

The second set of if (if else) statements would evaluate a number input and display the cheesy message based on the value, or if it was out of range, to make you re input that days temperature.

I understand that the else statement is linked to the closest if statement, unless brackets are added to prevent this. I thought my brackets were correct, but I keep getting [Error]'else' without previous if'. The red lines are the if and else statement I'd like to be linked, and tried to do so by enclosing the 2nd if statement in brackets.

The assignment doesn't require the error checking, but if I don't use some form of it I believe it will just loop. Again I have to use the last 4 lines due to instructors rules, and have to use scanf and not strings or arrays.

This program will ask the user what the temperature will be for each day of the week. The integer input from the keyboard will be tested in a series of IF tests and a message will be printed depending on the temperature.

Code] ....

#include <stdio.h>
#define MAX 100
#define MIN 0

int main() {
int day = 1;
int temp;

[Code] ....

View 10 Replies View Related

C++ :: Program Will Echo Letter (User Input) And Output Name Of The Day Of Week

Oct 21, 2012

Write a C++ program that does the following:

Prompt the user to enter a day of the week as M (or m), T, W, R, F, S, and U for Monday through Sunday respectively. The user may enter an upper or lower case letter.

When the user enters a character, the program will echo the letter and output the name of the day of the week.

Provide an error trap that reads something like "you have entered an invalid letter; program aborting." Suggestion: use a switch statement with the error trap as the default condition. it is not necessary to prompt for multiple inputs.

So I know how to get the program to echo back the letter and everything. What I am a little confused about is: will I have to define all the letters as their respective day? eg. make M== Monday. And if I do have to do that how would I get it to accept Upper and Lower case letters and recognize that that letter is == monday ect. ect.

Also my main problem is the switch statement as the error trap. I have never used the switch statement, but I know what they do. I just don't really understand how I would use it for an error trap. Am I suppose to just make a case for every other letter in the alphabet other then M T W R F S and U? Even if I do that then what if the user enters a number instead of a letter?

View 4 Replies View Related

C Sharp :: Linq - How To Group Values Week Wise And Store In Another Datatable

Apr 9, 2013

I have a datatable which comprises values from 1st January to march, something like this:

DataTable datatable = new DataTable("Employee");
datatable.Columns.Add("Date", typeof(string));
datatable.Columns.Add("Employee", typeof(string));
datatable.Columns.Add("Job1", typeof(double));
datatable.Columns.Add("Job2", typeof(double));  
datatable.Rows.Add(new Object[] { "1/4/2013", "A", 1.3, 2 });

[Code] ....

The result should look like this for Job1:

Employee 1/7-1/13 1/14-1/20 1/21-1/27 1/28-2/3 and so on...
A sum of values for this 7 days
B
C
D

I want to add all the values of Job1 for each employee in a time range which is one week starting from monday to sunday. How can I group the Job1 values week wise and store them in another datatable.

View 4 Replies View Related

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++ :: Printing A Triangle

Oct 7, 2013

What the heck is wrong with my logic? I just print a rectangle!!! I have played with thing for ever it seems. I thought the rotating part would be hard but now I find myself stuck.

Code:
#include <istream>
#include "triangle.h"
using namespace std;
void triangle::create_triangle() {

[Code] ....

View 13 Replies View Related

C :: Printing TXT File From URL

Feb 8, 2014

I need c source that give the url txt file and print the txt file

(get the http://site.com/text.txt) and print the (text.txt) file Content.

View 1 Replies View Related

C :: Printing Array With A New Value

Nov 21, 2013

I have an array, ary[size+1] and the original values entered and then another value, x, entered. I found the index of x that makes the array nondecreasing order

Code:

void InsertX (int ary[], int size, int x)
{
int i=0;
int j;
int index;
while(ary[i]<x)

[Code]...

But i can't figure out how to print the new array with x in it, using its index

View 6 Replies View Related

C :: Printing A Box Using 2D Array

May 8, 2013

how to print a box using 2d arrrays. i have to create a tetris game which a im stuck at this stage... so far i have tired i can only come out with this..my coding done so far is as follows:

Code:

#include <stdio.h>
#define ROW 15
#define COLUMN 15
void disp_box (char b[ROW][COLUMN])
}

[code]....

View 2 Replies View Related

C :: Program Not Printing Exactly

Mar 9, 2013

I expected this program to print out:

Code: Enter your desired monthly salary: $2000___
Gee! $2000.00 a month is $24000.00 a year. Instead, it printed out:
Code: Enter your desired monthly salary: $2000___

Gee! $2000.00 a month is $24000.00 a year. I don't understand how it got the extra nextline in the middle.

Here is the code:

Code:

#include <stdio.h>
int main(void) {
float salary;
printf("aEnter your desired monthly salary:");

[Code].....

View 2 Replies View Related

C++ :: Printing Name And GPA Of Student?

Feb 17, 2015

#include <iostream>
#include <string>
using namespace std;
struct studentType {
string name;
double gpa;

[Code] .....

View 11 Replies View Related

C++ :: Printing Out List Using OOP

May 17, 2013

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ios;
#include "Course.h"
#include <list>

[Code] ....

The program works well, except for the fact when it prints out the list (starting at the for-loop on line 65) each line is the same as the last, like it overwrites itself every time it traverses the while(true) loop.

View 9 Replies View Related

C++ :: Instead Of Printing In CMD Can Print Out In CSS / TXT?

Aug 13, 2014

I have previous threads asking how to make a list of words that were matched up be printed out into a .css or .txt

Is there anyway to make the words being printed out in CMD after debugging/compiling a script printed out in a .txt/.cpp file instead? CMD only has 300 lines. I need the outcome to be printed out elsewhere so more lines can be posted rather than 300.

View 8 Replies View Related

C/C++ :: Echo Not Printing

Mar 9, 2014

A simple UNIX shell that supports some built-in commands, external commands, and file redirection.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

[Code]....

View 6 Replies View Related







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