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
To draw a clustered cylinder chart, first select the data to be charted and then click the column button (insert tab | charts gr
d1i1m1o1n [39]
It is true that to <span>draw a clustered cylinder chart, first select the data to be charted and then click the column button (insert tab | charts group).</span>
5 0
4 years ago
If your cousin wanted to view information from the world wide web, what application software would you tell her to be sure she h
MAVERICK [17]
Well, I would say a web browser, like Mozilla Firefox, Safari for IOS, Windows Edge, Chrome, or Internet Explorer; and some anti-malware software, since there are multiple websites on the WWW that try to steal your information and give your device viruses.
6 0
3 years ago
TRUE/FALSE
algol [13]
<h2>Answer:</h2>

Following are given answers to each part with explanation:

<h2>Explanation:</h2>

1. lt takes multiple clock cycles to access data from memory.

The statement is TRUE.

Accessing data from memory acquires two steps. In first step the address is read and in second step we go to the address in order to access the data.

2.Each byte of memory has a unique address.

The statement is TRUE.

Each byte in the memory attains a unique address therefore we can access the data residing at each byte specifically by giving address.

3.The total memory used by all running programs can never be larger than the computer's physical memory.

The statement is TRUE.

The running parts are always a sub part o a system so combining them all cannot exceed the total size of computer's physical memory.

4.The lower half (or least significant half) of the EBX register is called BX.

The statement is TRUE.

BX is he least significant or lower half of the register EBX (extended BX).

5.The following data locations are in order of fastest access time to slowest access time: cache, registers, main memory.

The statement is TRUE.

Yes the order of data locations from faster to lower is given correctly:

Cache is accessed faster than registers and in the end comes main memory.

6.The ALU performs only addition, subtraction, multiplication, and division operation:s

The statement is FALSE.

ALU is an abbreviation of Arithmetic Logic unit. So it performs arithmetical operations such as addition, subtraction, multiplication, and division as well as the Logical operations that are AND OR NOT XOR.

7. The control unit (CU) coordinates the sequencing of execution steps in an instruction cycle.

The statement is TRUE.

As obvious from the name Control unit (CU) has assigned the coordination of execution of steps in sequence.

8.The EIP register is updated when an instruction is fetched.

The statement is TRUE.

Whenever the user retrieve any instruction from EIP or fetch the instruction from it. EIP gets updated.

9.The step to fetch an operand is always necessary in the instruction cycle.

The statement is TRUE.

Most of the Instructions demand an operand in the instruction cycle so that they could be operated on. While some instruction not demand the operand such as Exit. But majority demands the operand so it is true.

10.In an instruction cycle, the operands are fetched before the instruction is fetched.

The statement is FALSE.

The first part of instruction cycle is to fetch the instruction, whereas the operands are fetched after it. So the statement get FALSE.

<h3>I hope it will help you!</h3>
5 0
3 years ago
What do you ensure when you set up goals and objectives for your website design?
fredd [130]

Answer:

a

Explanation:

You know that if you searched brianly for the answer some one else has already answered the same question jut trynna help some one out to help save your points

7 0
3 years ago
Which data type is 2.5?<br> single<br> int<br> float<br> string
Ivenika [448]

2.5 is an example of a float.

Floats are numbers that have decimals.

5 0
3 years ago
Other questions:
  • Using Python
    14·1 answer
  • Which is an example of withholding you might see on your pay stub
    14·2 answers
  • This LEGENDARY character made a much-celebrated comeback in 2017. What was the name of the villain he faced in this epic tale?
    7·2 answers
  • This is not an appropriate business use for a wiki. editing corporate documents getting customer feedback project management pub
    11·1 answer
  • Which of the following website is arguably considered the best site to search for scholarships
    8·2 answers
  • What is an elliptic curve cryptosystem (ECC)?
    8·1 answer
  • Chen needs to configure a filter on the current folder and would like to filter by the sender of a message. Which tab in the Fil
    7·2 answers
  • You can use a(n) to call a function in response to an event?
    14·1 answer
  • Which tool can be used to increase the space between a bullet point or a number and text?
    11·2 answers
  • Once you select a theme, you__________ change the theme’s individual elements independently of each other.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!