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
ADVERTISEMENT
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
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
View Related
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Jul 20, 2013
I'm trying to display the contents of this map. I'm having some trouble where the program ceasing to display after "Index Contents."(lines 33 -40) If I move the display for loop right where I'm inserting the values (line 52) into the map I get output. I'm not sure where bug is.
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <regex>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef istream_iterator<string> isIterator;
typedef map<string, string> indexMap;
[Code] ....
View 1 Replies
View Related
Mar 5, 2015
I am trying to write a c program to convert centimeters to inches and then to feet. I have most of the code written but not sure how to debug it. I keep getting "0" as all of my output.
#include <stdio.h>
// Main Function
int main(void)
[Code]....
View 2 Replies
View Related
Jan 6, 2012
I got assignment at my school to display 2D array like this:
This is default array:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Now I have to print the default array like this:
1 2 6 7
3 5 8 13
4 9 12 14
10 11 15 16
I have tried some codes to do it myself but i had no success.
View 1 Replies
View Related
Feb 11, 2014
I have turbo c++ on windows xp SP2.....whenever i compile my code in turbo c++ i am getting output outside the screen.....but when i used code::block....i get the correct output...fits to screen ...
View 7 Replies
View Related
Feb 24, 2013
I'm trying to display an image from a stream data. But there is no image when getting image::from stream.
It's my source code:
Code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream))) {
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );
[Code]...
There is no image from data.
View 5 Replies
View Related
Jun 30, 2014
I'm currently working on a temperature conversion program using arrays / pointers as practice.
I will post the code below, its quite a bit lengthy and its also incomplete. Everything was going smoothly and I continually test my code as I write to completion, then I ran into a small road block.
My problem here is regarding the output from the first if statement in main. When I enter a value to convert from F to C. It successfully converts the first value I enter, but any other value after the first one during the loop in the first if statement, just shows long numbers of all sorts.
The output looks like this:
I kept checking the logic behind what I did, and for me it seems to be correct. Here is the code:
Code:
#include <stdio.h>
#define array_size 5
#define NEWLINE printf("
")
[Code].....
View 4 Replies
View Related
Oct 7, 2014
merging two arrays together and displaying them together in the end. However, I do not know how to start the merge function.
#include <iostream>
#include <assert.h>
using namespace std;
struct Array {
int* array; // point to the dynamically allocated array
}
[code]....
View 1 Replies
View Related
Oct 7, 2013
The user will enter the number of '*'s on the 1st row (ntop) and then the number of rows forming the trapezoid (nrows). (using <iostream>, cout)
For instance, an inverted trapezoid with 7 '*"s in the 1st row and 3 rows forming the inverted trapezoid looks like:
for (i = nrows; i >= 1; i--) {
for (j = 0; j >= nrows; j++) {
cout << " ";
} for (k=ntop; k >= 2; k--) {
cout << "*";
} }
The output is just blank as of now.
View 3 Replies
View Related
Oct 6, 2013
If the number 4 is entered, the output should be the following:
1: 1
2: 1, 2
3: 1, 3
4: 1, 2, 4,
My output, however, is different but I know its an error with the comma.f
1: 1, , ,
2: 1, 2, ,
3: 1, , 3,
4: 1, 2, , 4
Here is my code:
#include <iostream>
using namespace std;
int main()
{
[Code].....
View 1 Replies
View Related