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...
5) Create the following in a Java program Create a scanner Prompt the user to enter...
5) Create the following in a Java program Create a scanner Prompt the user to enter the name where the box of mail is shipping from and create the variable and relate to scanner Prompt the user to enter the name of destination where the box of mail will be shipped and create the variable and relate to scanner Prompt the user to enter the weight of the package and create variable to relate to scanner Calculate cost of shipping...
6) Create the following in a Java Program: Create payroll system Prompt the user to enter...
6) Create the following in a Java Program: Create payroll system Prompt the user to enter payroll information Employee name and create variable for scanner Hours worked Hourly pay rate Federal tax rate State tax rate Declare variable doubles for gross pay, federal, state and total deduction Display payroll statement example: Name of employee Hours worked Hourly pay rate Gross pay which is equal hours worked multiply hourly pay rate Federal withholding which is equal of gross pay multiply federal...
Java Program using Netbeans IDE Create class Date with the following capabilities: a. Output the date...
Java Program using Netbeans IDE Create class Date with the following capabilities: a. Output the date in multiple formats, such as MM/DD/YYYY June 14, 1992 DDD YYYY b. Use overloaded constructors to create Date objects initialized with dates of the formats in part (a). In the first case the constructor should receive three integer values. In the second case it should receive a String and two integer values. In the third case it should receive two integer values, the first...
Create a python program that will: prompt a user for a command Command get_data Level 1:...
Create a python program that will: prompt a user for a command Command get_data Level 1: Take one of the commands my_max my_min my_range my_sum mean median mode fib factorize prime Requirements: Your commands should be case-insensitive You should use python lists to store data You should NOT use built-in python math functions, or math libraries to compute these values Tips: Write one function that will convert a string with comma-separated numbers into a python list with the numbers. You...
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....
I need someone to create a program for me: Create a program that takes as input...
I need someone to create a program for me: Create a program that takes as input an employee's salary and a rating of the employee's performance and computes the raise for the employee. The performance rating here is being entered as a String — the three possible ratings are "Outstanding", "Acceptable", and " Needs Improvement ". An employee who is rated outstanding will receive a 10.2 % raise, one rated acceptable will receive a 7 % raise, and one rated...
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...
create a program that will verify a user's login credentials. The program should prompt the user...
create a program that will verify a user's login credentials. The program should prompt the user to enter his/her username and password at the keyboard. Then it should read the data from a data file named "login.txt". The file "login.txt" will contain a list of 3 valid usernames and passwords to verify the login information supplied by a user.  If the username and password entered by the user matches one of the sets read from the file, the program should print...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT