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
Marina86 [1]
3 years ago
10

Write a program that prompts the user to enter a person's date of birth in numeric form such as 8-27-1980. The program then outp

uts the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Similar conventions for the invalid values of month and year. (Note that your program must handle a leap year.)
Computers and Technology
1 answer:
Oksi-84 [34.3K]3 years ago
7 0

Answer:

The program to this question can be given as:

Program:

//define header file.

#include<iostream>

#include<string>

using namespace std;

class invalidDay              //define class.

{

string msg;                   //define variable as private.

public:

invalidDay()               //constructor.

{

msg="Day input is wrong";            

}

void showException()           //define function.

{

cout<<msg<<endl;

}

};

class invalidMonth              //define class.

{

string msg;             //define variable as private.

public:

invalidMonth()              //constructor.

{

msg="Month input is wrong";

}

void showException()           //define function.

{

cout<<msg<<endl;

}

};

class leapYear           //define class            

{

string msg;         //define variable as private.

public:

leapYear()                  //define constructor

{

msg="year input is wrong";

}

void showException()         //define function.

{

cout<<msg<<endl;

}

};

void read_date(int &day,int &month,int &year);         //declaration of function.

void read_date(int &d,int &m,int &y)                 //defination of function.

{    

  //function body.

cout<<"Enter day"<<endl;

cin>>d;

if(d<=0 ||d>31)

throw invalidDay();               //Exception.

cout<<"Enter month"<<endl;

cin>>m;

if(m<=0 ||m>=13)

throw invalidMonth();

cout<<"Enter year"<<endl;

cin>>y;

if(y%400==0||(y!=100&&y%4==0))

if(d>=30)

throw leapYear();

}

int main()                     //main function

{

   //define variable

int day,month,year;                  

string months[12]={"January","February","March",            

"April","May","June","July","August","September",

"October","November","December"};

//Exception handling.

try                               //try block

{

read_date(day,month,year);

cout<<"Date of Birth "<<months[month-1]<<" "<<day<<","<<year;

}  

//catch bolck.

catch(invalidDay id)

{

id.showException();

}

catch(invalidMonth im)

{

im.showException();

}

catch(leapYear ly)

{

ly.showException();

}

return 0;

}

Output:

Enter day

12

Enter month

12

Enter year

2019

Date of Birth December 12,2019.

Explanation:

In the above program firstly we define 3 class that is invalidDay, invalidMonth, and leapYear. In these classes, we define a method, variable, and constructor, and in the constructor, we holding the value of the msg(variable). Then we define a function that is read_data. This function collects all values from the user and throws into leap year function. In the last, we define the main function this function used exception handling. In the exception handling, we use multiple catch block with try block. After handling all the exception we called all function of the class.

You might be interested in
Does two core processors mean that it is twice as fast do you agree? why?
vlabodo [156]

Answer:

the friendships the following link and fill out our related information

Explanation:

consisting of a new one of the cell number of people who want

3 0
3 years ago
You have just performed a cpm analysis and have found that more than one path through the project network has zero slack values.
Alex787 [66]

Answer:

There are multiple critical paths

Explanation:

The critical path method (CPM), or critical path analysis (CPA), is an algorithm for scheduling a set of project activities. It is commonly used in conjunction with the program evaluation and review technique (PERT). A critical path is determined by identifying the longest stretch of dependent activities and measuring the time required to complete them from start to finish.

The essential technique for using CPM is to construct a model of the project that includes the following:

  •    A list of all activities required to complete the project (typically categorized within a work breakdown structure),
  •    The time (duration) that each activity will take to complete,
  •    The dependencies between the activities and,
  •    Logical end points such as milestones or deliverable items.      

Using these values, CPM calculates the longest path of planned activities to logical end points or to the end of the project, and the earliest and latest that each activity can start and finish without making the project longer. This process determines which activities are "critical" (i.e., on the longest path) and which have "total float" (i.e., can be delayed without making the project longer).

considering the above function of the cpm analysis because you have multiple path, there is tendency that more than path through the project network will have zero slack values.

5 0
3 years ago
What is the future of web development
Anna35 [415]

Answer:

Creating websites that can execute automated tasks and new programing languages revolving around web development.

Explanation:

7 0
2 years ago
Define quality control​
tangare [24]

Quality control is a system of maintaining standards in manufactured products by testing a sample of the output against the specification.

8 0
3 years ago
What is the likely long-term consequence of an increase in the relative percent of greenhouse gases in Earth’s atmosphere?
NemiM [27]

Answer:

Earth's average temperature will increase.

Explanation:

5 0
3 years ago
Other questions:
  • Interpretations of​ Moore's law assert​ that:
    13·1 answer
  • To enter a typed number into a cell, you press Tab or Backspace?​
    7·2 answers
  • Which of the following is a group of email names and addresses used for mass distribution of a message?
    5·1 answer
  • Extending the web server functionality implies that the web server and the web-to-database middleware will properly communicate
    10·1 answer
  • Suppose that the domestic production of computer games creates enjoyment for those who play the games. Domestic production of co
    14·1 answer
  • They have outlined their technical needs and have sent some of the documentation along with the potential provider's SLAs and te
    14·1 answer
  • The following are part of characteristics of a software requirement specification.
    6·1 answer
  • Which statement assigns the value 140 to the variable streetNumber in Python?
    13·1 answer
  • Imagine that you are preparing a multimedia presentation. What are the four things you need to consider when getting started?
    14·2 answers
  • Which pair of devices have the same input motion and different outputs?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!