Question

code has to be in C++... Need a completely documented application that uses classes and POINTERS...

code has to be in C++... Need a completely documented application that uses classes and POINTERS in conjunction with overload operators..... Write a program that puts out dates in various formats. Dates are commonly printed In several different formats in business correspondence , Two of the more common formats are : 07/21/1955 ;
july 21, 1955 ..Write a program that reads a date in the first format and prints that date in the second format. make sure to use pointers !!!!!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ Program:

/* C++ Program that reads day, month, year from user and then displays date */

#include<iostream>
#include<iomanip>
#include<string>

using namespace std;

//Date class definition
class Date
{
//Variables to hold date
private:
int month, day, year;

public:
//Parameterized constructors
Date(int d, int m, int y)
{
day = d;
month = m;
year = y;
}

//Default Constructor
Date()
{
month = 12;
day = 5;
year = 2018;
}

//Setter methods
void setDay(int val) {day = val;}
void setMonth(int val) {month = val;}
void setYear(int val) {year = val;}

//Getter methods
int getDay() {return day;}
int getMonth() {return month;}
int getYear() {return year;}


friend ostream &operator<<( ostream &output, const Date *d)
{
string monthNames[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
output << monthNames[d->month-1] << " " << d->day << ", " << d->year;

return output;
}

friend istream &operator>>( istream &input, Date *d )
{
char ip;
input >> d->month >> ip >> d->day >> ip >> d->year;
return input;
}
};

//Main function
int main()
{
Date *dateObj;

//Reading date
cout << "Enter a date with this format mm/dd/yyyy ===> ";
cin >> dateObj;

//Printing date
cout << "\nHere the results :";
cout << "\nMonth : " << dateObj->getMonth();
cout << "\nDay : " << dateObj->getDay();
cout << "\nYear : " << dateObj->getYear();

cout << "\n\nFull Format ===> " << dateObj;

cout << "\n";
return 0;
}
____________________________________________________________________________________________________

Sample Run:

Add a comment
Know the answer?
Add Answer to:
code has to be in C++... Need a completely documented application that uses classes and POINTERS...
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
  • CODING IN JAVA Dates are printed in several common formats. Two of the more common formats...

    CODING IN JAVA Dates are printed in several common formats. Two of the more common formats are: 07/21/55 and July 21, 1955 Write a program that reads a date in the first format and prints that date in the second format. Prompt the user and accept user input for the date in MM/DD/YYYY format. Retrieve the month portion of the date entered and convert it to an integer. Do the same thing for day and year Create a string named...

  • Need help with code in C# Create an application that reads a file named Accounts.txt. Your application should load the file and display back the results. The application should allow the user to enter...

    Need help with code in C# Create an application that reads a file named Accounts.txt. Your application should load the file and display back the results. The application should allow the user to enter additional entries and save them back to the same file. The CSV file should contain the following fields: AccountName, InvoiceDate, DueDate, AmountDue If the CSV file contains invalid data you want to inform the user which row contained bad data. Below is an example of what...

  • I need one file please (C++)(Stock Market) Write a program to help a local stock trading...

    I need one file please (C++)(Stock Market) Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted...

  • c++ programming no use of classes use of functions pseudo code with comments Requirement: Provide one...

    c++ programming no use of classes use of functions pseudo code with comments Requirement: Provide one application for a business store that sale 2 models of one proo model FA218 and model FA318. The application first provides the menu to allow users can select one of the following tasks per time and when they finish one task, they can continue the application to select other task from the menu until they choose exit. All the output on the screen and...

  • please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you...

    please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you are going to write a program to represent various types of packages offered by package-delivery services. You need to create an inheritance hierarchy to represent various types of packages with different shipping options and associated costs. The base class is Package and the derived classes are FlatRatePackage and OvernightPackage. The base class Package includes the following attributes: • Sender information: senderName (string), senderAddress (string),...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

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