Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,213 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 946 people online right now. Registration is fast and FREE... Join Now!




DayOfTheWeek

 
Reply to this topicStart new topic

DayOfTheWeek, C++ programming

ITChief
post 15 Mar, 2008 - 05:31 PM
Post #1


New D.I.C Head

*
Joined: 15 Mar, 2008
Posts: 17


My Contributions


Write a program that contains a class that implements the days of the week. The program should be able to perform the following on an object of a class.
1. Set the day
2. Print the day to the computer monitor(not the printer)
3. Return the day

Create a new class called DayOfTheWeek. The class should have a data member that can store the day of the week such as Mon for Monday, Tues for Tuesday etc...

Create the necessary member functions that will perform the required operations outlined in the lab summary above.

Call these functions setDay, printDay and getDay.

Write a main program that will instantiate two objects of the class DayOfTheWeek. Use these objects to test the various operations on this class.

DayOfTheWeekHEA~1

#include <string>
using std::string;
class DayOfTheWeek
{
private:
string day
string hour

public:
void setday(string, string);
void printday();
string getday();
};

DayOfTheWeekIMP
#include <iostream>
#include <string>
#include "DayOfTheWeek.h"

using manespace std;

void DayOfTheWeek::setdayinfo(string day, string hour)
{
Monday = mon;
Tuesday = tues;
Wednesday = weds;
Thursday = thurs;
Friday = fri;
Saturday = sat;
Sunday = sun;
}
void DayOfTheWeek::printDay()
{
cout << "Day: " << day << endl;
cout << "Hour: " << hour << endl;
}
string DayOfTheWeek::getday()
{
return day;
}

This post has been edited by ITChief: 15 Mar, 2008 - 05:53 PM
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 08:21PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month