subject
Computers and Technology, 21.03.2020 05:34 peno211

Writing a Modular Program in C++

In this lab, you add the input and output statements to a partially completed C++ program. When completed, the user should be able to enter a year, a month, and a day. The program then determines if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.

Notice that variables have been declared for you.

Write the simulated housekeeping() function that contains the prompts and input statements to retrieve a year, a month, and a day from the user.

Include the output statements in the simulated endOfJob() function. The format of the output is as follows:

month/day/year is a valid date.

or

month/day/year is an invalid date.

Execute the program entering the following date: month = 5, day = 32, year = 2014. Record the output of this program.

Execute the program entering the following date: month = 9, day = 21, year = 2002. Record the output of this program.



/* Program Name: BadDate. cpp
Function: This program determines if a date entered by the user is valid.
Input: Interactive
Output: Valid date is printed or user is alerted that an invalid date was entered
*/

#include
bool validateDate(int, int, int);
using namespace std;
int main()
{
// Declare variables

int year;
int month;
int day;
const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31;
bool validDate = true;

// This is the work of the housekeeping() method
// Get the year, then the month, then the day
cout<<"Enter the year"< cin>>year;
cout<<"Enter the month"< cin>>month;
cout<<"Enter the day"< cin>>day;

// This is the work of the detailLoop() method
// Check to be sure date is valid

if(year <= MIN_YEAR) // invalid year
validDate = false;
else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month
validDate = false;
else if (day < MIN_DAY || day > MAX_DAY) // invalid day
validDate = false;

// This is the work of the endOfJob() method
// test to see if date is valid and output date and whether it is valid or not
if(validDate == true);
{
// Output statement

cout< }
else
{
// Output statement
cout<
}

} // end of main() function

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
question
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
question
Computers and Technology, 24.06.2019 17:40
The value of sin(x) (in radians) can be approximated by the alternating infinite series create a function (prob3_2) that takes inputs of a scalar angle measure (in radians) and the number of approximation terms, n, and estimates sin(x). do not use the sin function in your solution. you may use the factorial function. though this can be done without a loop (more efficiently), your program must use (at least) one. you may find the mod() function useful in solving the problem.
Answers: 1
You know the right answer?
Writing a Modular Program in C++

In this lab, you add the input and output statements t...
Questions
question
Mathematics, 01.03.2021 14:00
question
English, 01.03.2021 14:00
question
Mathematics, 01.03.2021 14:00
question
Biology, 01.03.2021 14:00
question
Mathematics, 01.03.2021 14:00
question
Mathematics, 01.03.2021 14:00
Questions on the website: 13722367