1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
luda_lava [24]
3 years ago
14

A date consists of a month, day, and year. Consider the class Date of such dates. Suppose that Date represents the month, day, a

nd year as integers. For example, July 4, 1776, is month 7, day 4, and year 1776. a. Write specifi cations for a method within Date that advances any given date by one day. Include a statement of purpose, the preconditions and postconditions, a description of the arguments, and a description of any return value. b. Write a C++ implementation of this method. Design and specify any other method that you need. Include comments that will be helpful to someone who will maintain your implementation in the future.
Computers and Technology
1 answer:
Dominik [7]3 years ago
4 0

Answer:

#include <iostream>

#include <cmath>

using namespace std;

class Date

{

public:

Date ();

Date ( int mn, int day, int yr); // constructor

void display(); // function to display date

int GetMonth();

void SetMonth(int mn);

~Date();

private:

int month, day, year;

};

// constructor definition

Date::Date ()

{

month = day = year = 1;

}

Date::Date (int mn, int dy, int yr)

{

static int length[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

month = mn;

day = dy;

year = yr;

}

void Date::display()

{

static string name[] = {"nothing", "January", "February", "March", "April",

"May", "June", "July", "August", "September", "October",

"November", "December" };

cout << '\n' << name[month] << ' ' << day << "," << year << '\n';

}

Date::~Date()

{

cout << "Thank You for using DateLine Services and have a nice date\n";

}

int Date::GetMonth()

{

return month;

}

// Precondition: 1 <= mn <= 12

void Date::SetMonth(int mn)

{

month = mn;

}

int main()

{

Date mydate(1, 2, 1993);

Date date2(4,12,1994);

Date date3;

mydate.display();

date2.display();

date3.display();

}

Explanation:

You might be interested in
Assume user_name equals "Tom" and user_age equals 22. What is printed on the console when the following statement is executed? c
12345 [234]

Answer:

The ouput of the given code is :

22

is "Tom's age.

Explanation:

Here in this code the variable user_name and user_age are initialized to  "Tom" and 22 respectively as statement is given in the question i.e  cout << user_age << " \nis " + user_name << "'s age.";.This line will print the user_age i.e 22 after that the control moves to the next line and print is "Tom's age.

Following are the code in c++

#include <iostream> // header file

#include <string>

using namespace std;

int main() // main function

{

   string user_name="Tom";

   int user_age= 22;

cout << user_age << " \nis " + user_name << "'s age.";

return 0;

}

Output:

22

is "Tom's age.

8 0
3 years ago
The number of operations executed by algorithms A and B is 40n2 and 2n3, respectively. Determine n0 such that A is better than B
Tom [10]

Answer:

Given that:

A= 40n^2

B = 2n^3

By given scenario:

40n^2=2n^3

dividing both sides by 2

20n^2=n^3

dividing both sides by n^2 we get

20 = n

Now putting n=20 in algorithms A and B:

A=40n^2

= 40 (20)^2

= 40 * (400)

A= 16000

B= 2n^3

= 2 (20)^3

= 2(8000)

B= 16000

Now as A and B got same on n = 20, then as given:

n0 <20 for n =20

Let us take n0 = 19, it will prove A is better than B.

We can also match the respective graphs of algorithms of A and B to see which one leads and which one lags, before they cross at n= 20.

8 0
3 years ago
You cannot advance slides during the slide show by pressing the PAGE DOWN key
noname [10]
<span>You cannot advance slides during the slide show by pressing the PAGE DOWN key.
This is a true statement.
</span>
4 0
3 years ago
Create a 4x5 matrix with ones everywhere and zeros on the last row.
Stells [14]

Answer:

#include <iostream>

using namespace std;

int main() {

   int a[4][5];//declaring a matrix of 4 rows and 5 columns.

   for(int i=0;i<4;i++)

   {

       for(int j=0;j<5;j++)

       {

           if(i==3)//initializing last row as 0.

           {

               a[i][j]=0;

           }

           else//initializing last row as 1.

           {

               a[i][j]=1;

           }

       }

   }

   for(int i=0;i<4;i++)

   {

       for(int j=0;j<5;j++)

       cout<<a[i][j]<<" ";//printing the matrix.

       cout<<endl;

   }

return 0;

}

Output:-

1 1 1 1 1  

1 1 1 1 1  

1 1 1 1 1  

0 0 0 0 0

Explanation:

I have created a matrix of size 4 rows and 5 columns.I have used for loops to fill the array.To fill the last row with 0 i have used if statement.else we are filling it with 1.

7 0
3 years ago
How much does 1 American tank cost on gas for a regular mission? Depending on your answer, I will give you the right amount of p
dem82 [27]
Most of the cars or other vehicles in the United States regularly have tanks that can hold up to 12 gallons worth of gas. The price of gas in not consistent. Sometimes prices are high and sometimes prices are low. Just like to day the price of a gallon is worth $2.2. But in an average, gas costs $3.8 per gallons. Therefore, on a regular basis a standard American which can hold 12 gallons costs $46.2.
5 0
3 years ago
Other questions:
  • A tornado may be approaching if you observe which of the following?
    15·1 answer
  • How do you know if a remote host is alive or not?
    5·1 answer
  • Which of the following attributes of a website indicates a more reliable source for information?
    8·1 answer
  • If the base-10 system stops with the<br> number 9, then why isn't it called<br> base-9?
    15·1 answer
  • Run a Monte Carlo simulation on this vector representing the countries of the 8 runners in this race: runners &lt;- c("Jamaica",
    14·1 answer
  • How can we display outputs of DIR one screenful at a time? There are at least two different ways, and either one is acceptable.
    8·1 answer
  • How to make a harmonic mean algorithm in bash Linux?
    15·1 answer
  • 11) A single inheritance model means: * A) A class can only have one parent class (superclass) B) A class can only have one chil
    7·1 answer
  • Maria is conducting a security investigation and has identified a suspect. The suspect is an employee of the organization who ha
    15·1 answer
  • Functions are used to _________
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!