Question

for the following code I need the source code and output screenshot (includes date/time) in a...

for the following code I need the source code and output screenshot (includes date/time) in a PDF format. I keep getting an error for the #include "dayType.hpp"

dayType.cpp

#include"dayType.hpp"
    string dayType::weekday[7] = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };
    //set the day
    void dayType::setDay(string day){
        cout << "Set day to: " ;
        cin >> dayType::day;
        for(int i=0; i<7; i++) {
            if(dayType::weekday[i]==dayType::day) {
                dayType::markDay = i;
            }
        }

    } 

    //print the day
    void dayType::printDay() {
        cout << "Day = " << dayType::day << endl;
    }

    string dayType::getDay(){
       return  dayType::weekday[dayType::markDay]; 
    }

    //print the next day
    string dayType::getNextDay(){
        string next;
        if(markDay == 6){
           next = dayType::weekday[0];
        }
        else{
            next = weekday[markDay+1];
        }

       return  next; 
    }

    //print the previous day
    string dayType::getPrevDay(){
        string prev;
        cout << markDay << endl;
        if(markDay == 0){
            prev =weekday[6];
        }
        else{
            prev = weekday[markDay-1];
        }
       return  prev; 
    }

    //add days
    string dayType::addDays(){
        int addDay = 0, i = markDay, count=0;
        cout << "How many days do you want to add: ";
        cin >> addDay;

        while(count
#ifndef DAYTYPE_HPP #define DAYTYPE_HPP #include #include using namespace std; class dayType { //everything can access these public: static string weekday[7]; void setDay(string day); //set the day void printDay(); //print the day string getDay(); string getNextDay(); string getPrevDay(); string addDays(); dayType(); //default constructor dayType(string day); // //only accessable by class children protected: //only accessable by class private: int markDay ; string day ; }; #endif main.cpp 
#include"dayType.hpp"

int main() {
    dayType myDayType;
    myDayType.setDay("Sun");
    
    myDayType.printDay();
    
    myDayType.getDay();
    cout << "Tommorow is " << myDayType.getNextDay() << endl;
    cout << "Yesterday is " << myDayType.getPrevDay() << endl;
    cout << "Return day is " << myDayType.addDays() << endl;
}

.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
SOURCE CODE:

--------------------------------------------------------------------------------------

/* dayType.hpp */

#ifndef DAYTYPE_HPP
#define DAYTYPE_HPP

#include<iostream>
#include<string>

using namespace std;
class dayType
{
  //everything can access these
  public:

  static string weekday[7];
  void setDay(string day); //set the day
  void printDay(); //print the day
  string getDay();
  string getNextDay();
  string getPrevDay();
  string addDays(int addDay);
  dayType(); //default constructor
  dayType(string day); // constructor

  //only accessable by class children
  protected:

  //only accessable by class
  private:
    int markDay ; string day ;

};

#endif

/* END OF dayTYpe.hpp */


--------------------------------------------------------------------------------------

/* dayType.cpp */

#include "dayType.hpp"

string dayType::weekday[7] = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };

//default constructor
dayType::dayType(){
  dayType::day = "Sun";
  dayType::markDay = 0;
}

//default constructor
dayType::dayType(string day){
  dayType::day = day;
  for(int i=0; i<7; i++) {
      if(dayType::weekday[i]==day) {
          dayType::markDay = i;
      }
  }
}

//set the day
void dayType::setDay(string day){
  dayType::day = day;
  for(int i=0; i<7; i++) {
      if(dayType::weekday[i]==day) {
          dayType::markDay = i;
      }
  }
}

//print the day
void dayType::printDay() {
  cout << "Day = " << dayType::day << endl;
}

string dayType::getDay(){
  return  dayType::weekday[dayType::markDay];
}

//print the next day
string dayType::getNextDay(){
  string next;
  if(markDay == 6){
      next = dayType::weekday[0];
  }
  else{
      next = weekday[markDay+1];
  }
  return next;
}

//print the previous day
string dayType::getPrevDay(){
  string prev;
  if(markDay == 0){
      prev = weekday[6];
  }
  else{
      prev = weekday[markDay-1];
  }
  return  prev;
}

//add days
string dayType::addDays(int addDay){
  markDay = (markDay + addDay) % 7;
  return dayType::weekday[dayType::markDay];
}

/* END OF dayType.cpp */

--------------------------------------------------------------------------------------

/* main.cpp */

#include"dayType.hpp"

int main() {
  dayType myDayType;
  
  myDayType.setDay("Wed");
  
  myDayType.printDay();
  
  myDayType.getDay();
  cout << "Tommorow is " << myDayType.getNextDay() << endl;
  cout << "Yesterday was " << myDayType.getPrevDay() << endl;
  cout << "Return day is " << myDayType.addDays(2) << endl;
}

/* END OF main.cpp */

--------------------------------------------------------------------------------------

SAMPLE OUTPUT:

Add a comment
Know the answer?
Add Answer to:
for the following code I need the source code and output screenshot (includes date/time) in a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ Program. You have a following class as a header file (dayType.h) and main()....

    Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public:     static string weekDays[7];     void print() const;     string nextDay() const;     string prevDay() const;     void addDay(int nDays);     void setDay(string d);     string getDay() const;     dayType();     dayType(string d); private:     string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...

  • Hello, I have a bug in my code, and when I run it should ask the...

    Hello, I have a bug in my code, and when I run it should ask the user to enter the month and then the year and then print out the calendar for the chosen month and year. My problem with my code is that when I run it and I enter the month, it doesn't ask me for the year and it prints all the years of the month I chose. Please help! Code: #include "calendarType.h" #include <iostream> using namespace...

  • The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried t...

    The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...

  • Fix my code, if I the song or the artist name is not on the vector,...

    Fix my code, if I the song or the artist name is not on the vector, I want to user re-enter the correct song or artist name in the list, so no bug found in the program #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; class musicList{ private: vector<string> songName; vector<string> artistName; public: void addSong(string sName, string aName){ songName.push_back(sName); artistName.push_back(aName); } void deleteSongName(string sName){ vector<string>::iterator result = find(songName.begin(), songName.end(), sName); if (result == songName.end()){ cout << "The...

  • I need help with understanding dummy nodes in doubly-linked lists. Here is the code that I...

    I need help with understanding dummy nodes in doubly-linked lists. Here is the code that I have right now. ************city.h**************** #ifndef city_h #define city_h #include <string> using namespace std; class City{ public: City () { name = "N/A"; population = 0; } City (string nm, unsigned int pop){ name = nm; population = pop; } void setName (string name) { this -> name = name; } void setPopulation (unsigned int population){ this -> population = population; } string getName() const...

  • Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string;...

    Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...

  • -can you change the program that I attached to make 3 file songmain.cpp , song.cpp ,...

    -can you change the program that I attached to make 3 file songmain.cpp , song.cpp , and song.h -I attached my program and the example out put. -Must use Cstring not string -Use strcpy - use strcpy when you use Cstring: instead of this->name=name .... use strcpy ( this->name, name) - the readdata, printalltasks, printtasksindaterange, complitetasks, addtasks must be in the Taskmain.cpp - I also attached some requirements below as a picture #include <iostream> #include <iomanip> #include <cstring> #include <fstream>...

  • I have 2 issues with the C++ code below. The biggest concern is that the wrong...

    I have 2 issues with the C++ code below. The biggest concern is that the wrong file name input does not give out the "file cannot be opened!!" message that it is coded to do. What am I missing for this to happen correctly? The second is that the range outputs are right except the last one is bigger than the rest so it will not output 175-200, it outputs 175-199. What can be done about it? #include <iostream> #include...

  • C++ - I have a doubly linked list, but I haven't been able to get the...

    C++ - I have a doubly linked list, but I haven't been able to get the "reverse list" option in the code to work(It's option #in the menu in the program). I received this guidance for testing: Test 4 cases by entering (in this order) c,a,z,k,l,m This tests empty list, head of list, end of list and middle of list. Then delete (in this order) a,z,l. This tests beginning, end and middle deletes. This exhaustively tests for pointer errors. #include...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT