Question

In: Computer Science

Create a program that will prompt me for each of the following items: 1. Date of...

Create a program that will prompt me for each of the following items:

1. Date of Birth

2. Typical wake up time

3. Next Dentist Appointment. ( Date and Time)

Create a Date structure and a method to load and return the date structure. Create a Time-of-day structure and a method to load and return the Time-of-day structure. Create a DateTime structure that includes the Date and Time-Of-Day structure.

The Date structure should include year, month, day. The Time-of-day structure should include hour and minute.

Use these structures and apply them to the processing of the input of the 3 items listed above. Display the structured data for each of the 3 listed data items.

Avoid redundancy where possible ( In other words, avoid duplicated code and write method(s) as needed to avoid duplication). This primarily applies to the processing of item 3.

Solutions

Expert Solution

Code:-

#include<iostream>
using namespace std;
//Create structure of type date with year, month and day as members.
typedef struct Date
{
   int year;
   char month[100];
   int day;
}date;
//Create structure of type time of day with hour and minute as members.
typedef struct Time_Of_Day
{
   int hour;
   int minute;
}timeOfDay;
//Create structure datetime and data members are the objects of date and timeOfDay structure because it has to store both.
typedef struct DateTime
{
   date dobj;
   timeOfDay tobj;
}dateTime;
//Create method to take input for date structure
date input_date()
{
   date date_obj;
   cout<<"Enter Year: ";
   cin>>date_obj.year;
   cout<<"Enter Month: ";
   cin>>date_obj.month;
   cout<<"Enter Day: ";
   cin>>date_obj.day;
   return date_obj;
}
//Create method to take input for timeOfDay structure
timeOfDay input_time()
{
   timeOfDay time_obj;
   cout<<"Enter Hour: ";
   cin>>time_obj.hour;
   cout<<"Enter Minute: ";
   cin>>time_obj.minute;
   return time_obj;
}
//Create method to print date structure. Here, pass by reference is used
void output_date(date& d)
{
   cout<<d.year<<"-"<<d.month<<"-"<<d.day;
}
//Create method to print timeOfDay structure. Here also, pass by reference is used
void output_time(timeOfDay& td)
{
   cout<<td.hour<<":"<<td.minute;
}
//Driver code to test.
int main()
{
   //Create objects of all the structures.
   date date_obj;
   timeOfDay time_obj;
   DateTime dt_obj;
   //Input date of birth
   cout<<"Enter your date of birth:\n";
   date_obj=input_date();
   //input wake up time
   cout<<"Enter your typical wake up time:\n";
   time_obj=input_time();
   //input appointment date and time
   cout<<"Enter your next dentist appointment date and time:\n";
   dt_obj.dobj=input_date();
   dt_obj.tobj=input_time();
   cout<<endl<<endl;
   //display DOB
   cout<<"Your Date Of Birth is: ";
   output_date(date_obj);
   cout<<endl;
   //display wake up time
   cout<<"Your Typical Wake Up Time is: ";
   output_time(time_obj);
   cout<<endl;
   //display dentist's appointment date and time
   cout<<"Your Next Dentist Appointment is on: ";
   output_date(dt_obj.dobj);
   cout<<" ";
   output_time(dt_obj.tobj);
   cout<<endl;
   //END of driver code
   return 0;
}

Output:-

Please UPVOTE thank you...!!!


Related Solutions

Create a program that will loop and prompt to enter the highlighted data items in the...
Create a program that will loop and prompt to enter the highlighted data items in the structure below. This is every item except customerNumber , isDeleted and newLine; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; struct Customers { long customerNumber; char name[NAME_SIZE]; char streetAddress_1[STREET_SIZE]; char streetAddress_2[STREET_SIZE]; char city[CITY_SIZE]; char state[STATE_CODE_SIZE]; int zipCode;     char isDeleted;     char newLine; }; Always set the item isDeleted to 'N' and...
Create in Java a program that will prompt the user to enter aweight for a...
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
Create a program that creates a sorted list from a data file. The program will prompt...
Create a program that creates a sorted list from a data file. The program will prompt the user for the name of the data file. Create a class object called group that contains a First Name, Last Name, and Age. Your main() function should declare an array of up to 20 group objects, and load each line from the input file into an object in the array. The group class should have the following private data elements: first name ,last...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt the user if they'd like to (each action is a function): See the list Display all items (if any) in the list Add item to their list Confirm with the user before adding item (y/n or yes/no) If they enter a duplicate item, notify them the item already exists Remove items from their list Confirm with the user before removing item (y/n or yes/no)...
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Create a program that will prompt for user information for a Web site. Use a structure...
Create a program that will prompt for user information for a Web site. Use a structure to store the data. The structure will need to include the following items: First Name - string Last Name - string Full Name - string Birth Date   - int (assume format yyyymmdd) IsLeasingAutomobile - bool yearlySalary - float Create a single structure from the items listed above. Prompt for all items except "Full Name" and load the input directly into a variable based on...
C++ * Program 2:      Create a date class and Person Class.   Compose the date class...
C++ * Program 2:      Create a date class and Person Class.   Compose the date class in the person class.    First, Create a date class.    Which has integer month, day and year    Each with getters and setters. Be sure that you validate the getter function inputs:     2 digit months - validate 1-12 for month     2 digit day - 1-3? max for day - be sure the min-max number of days is validate for specific month...
Create a JavaFX program in java that does the following items: Display a drawing area of...
Create a JavaFX program in java that does the following items: Display a drawing area of dimension 500 x 400, with a black background. Provides a radio button group to allow the user to select one of the following three colors: red, green, and blue. Upon startup, the red radio button should be selected. Each time the user clicks in the drawing area, a circle of size 10 of the color selected by the radio button group in item 2...
For each of the following items, tell me where they would go on a balance sheet...
For each of the following items, tell me where they would go on a balance sheet or that they would not go on a balance sheet. I want the name of the line on the balance sheet and the section (i.e. accounts payable in current liabilities). You buy fertilizer in December to use the next spring. The fertilizer will not be delivered until it is used. The costs associated with planting winter wheat. You sold hay to a neighbor, but...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT