Question

I am trying to solve the following C++ problem over structures. I am having trouble with...

I am trying to solve the following C++ problem over structures. I am having trouble with the very last structure and I made a comment next to where I am confused. I included the assignment instructions and my current code. I would appreciate if anyone can help me explain what I need to do for the last structure. Thank you.

Assignment Instructions

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.

My Code:
#include
#include
#include
using namespace std;


struct date
{
   int year;
   int month;
   int day;
};

struct timeOfDay
{
   int hour;
   int minute;
};


struct dateTime
{
   date apptDate;
   timeOfDay apptTime;
};


void getDate(date &);
void getTime(timeOfDay &);

void getDate(date &d)
{

   cout << "Enter Month (Up to 2 digits):";
   cin >> d.month;
   cout << "Enter Day (Up to 2 digits):";
   cin >> d.day;
   cout << "Enter Year:";
   cin >> d.year;
  
}

void getTime(timeOfDay &t)
{
  
   cout << "Hour:";
   cin >> t.hour;
   cout << "Minute:";
   cin >> t.minute;


}

void outputDate(date &d)
{
   cout << "Your date of birth is ";
   cout << d.year << "-" << d.month << "-" << d.day << endl;
  
}

void outputTime(timeOfDay &t)
{
   cout << "Your typical wake up time is ";
   cout << t.hour << ":" << t.minute << endl;
}

int main()
{
   date d;
   timeOfDay t;
   dateTime apt;

   cout << "Enter your date of birth" << endl;
   getDate(d);
   outputDate(d);

   cout << "When is your typical wake up time?" << endl;
   getTime(t);
   outputTime(t);

   cout << "When is your next dentist appointment?";
   cin >> // I am confused here
  
   system("pause");
  
}

Homework Answers

Answer #1

If you need any corrections kindly comment.

Please give a Thumps Up if you like the answer.

Program

#include<iostream>
#include<iomanip>
using namespace std;

struct date
{
   int year;
   int month;
   int day;
};

struct timeOfDay
{
   int hour;
   int minute;
};


struct dateTime
{
   date apptDate;
   timeOfDay apptTime;
};


void getDate(date &);
void getTime(timeOfDay &);

void getDate(date &d)
{

   cout << "Enter Month (Up to 2 digits):";
   cin >> d.month;
   cout << "Enter Day (Up to 2 digits):";
   cin >> d.day;
   cout << "Enter Year:";
   cin >> d.year;

}

void getTime(timeOfDay &t)
{

   cout << "Hour:";
   cin >> t.hour;
   cout << "Minute:";
   cin >> t.minute;


}

void outputDate(date &d)
{

   cout << d.year << "-" << d.month << "-" << d.day << endl;

}

void outputTime(timeOfDay &t)
{

   cout << t.hour << ":" << t.minute << endl;
}

int main()
{
   date d;
   timeOfDay t;
   dateTime apt;

   cout << "Enter your date of birth" << endl;
   getDate(d);
cout << "Your date of birth is ";
   outputDate(d);

   cout << "When is your typical wake up time?" << endl;
   getTime(t);
cout << "Your typical wake up time is ";
   outputTime(t);

   cout << "When is your next dentist appointment?";
getDate(apt.apptDate);
getTime(apt.apptTime);

   cout<< "Your appointment date is :";
outputDate(apt.apptDate);

cout<< "Your appointment time is :";
outputTime(apt.apptTime);
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
No matter what I do I cannot get this code to compile. I am using Visual...
No matter what I do I cannot get this code to compile. I am using Visual Studio 2015. Please help me because I must be doing something wrong. Here is the code just get it to compile please. Please provide a screenshot of the compiled code because I keep getting responses with just code and it still has errors when I copy it into VS 2015: #include <iostream> #include <conio.h> #include <stdio.h> #include <vector> using namespace std; class addressbook {...
How to stop the program from exiting after display detail. When there is food detail, it...
How to stop the program from exiting after display detail. When there is food detail, it will display and exit the program. What can i do to make it not exit the program and back to main menu. #include <iostream> #include <iomanip> #include<string.h> using namespace std; struct food{ int order_id; string food_code,flavor,customer_id; string address,name; int weight,unit_price,qty,contact_number; struct food *next; };    class Foodsystem{ food *head,*temp,*temp2,*end; static int id;    public: Foodsystem(){ head=NULL;end=NULL;} void Place_Order(); void View_food_details(); void Modify_food_details(); void Delete_food_details();...
C++ Please and thank you. I will upvote Read the following problem, and answer questions. #include<iostream>...
C++ Please and thank you. I will upvote Read the following problem, and answer questions. #include<iostream> using namespace std; void shownumbers(int, int); int main() { int x, y; cout << "Enter first number : "; cin >> x; cout << "Enter second number : "; cin >> y; shownumbers(x, y); return 0; } void shownumbers(int a, int b) { bool flag; for (int i = a + 1; i <= b; i++) { flag = false; for (int j =...
i want to complete this code to insert a new node in the middle of list...
i want to complete this code to insert a new node in the middle of list (take a node data from user, search the node and insert new node after this node). this is the code #include <iostream> #include <stdlib.h> using namespace std ; struct Node{                int data;                Node *link ;}; struct Node *head=NULL, *tail=NULL; /* pointers to Node*/ void InsertFront(); void InsertRear(); void DeleteFront(); void DeleteRear(); int main(){                int choice;                do{                               cout << "1:...
C++ PROGRAM When I input 3 S P R, it was suppoesed to pop up L...
C++ PROGRAM When I input 3 S P R, it was suppoesed to pop up L W T. But it showed L L L.IDK why the moveNo is not working. I am asking for help, plz dont put some random things on it. main.cpp #include <iostream> #include "computer.h" #include "human.h" #include "referee.h" using namespace std; int main() {     human h;     computer c;     referee r;     r.compare(h,c);     return 0; } computer.cpp #include<iostream> #include "computer.h" using namespace std;...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
Menu.cpp isn't working. C++  utilize inheritance to create a banking app. The architecture of the app is...
Menu.cpp isn't working. C++  utilize inheritance to create a banking app. The architecture of the app is up to you as long as you implement some form of inheritance. Below is my code however the credit and the actual menu isn't working. Can i get some help on getting the menu to work properly. // BankAccount.h #ifndef ACCOUNT_H #define ACCOUNT_H #include <string> #include <iostream> using namespace std; class BankAccount { protected : int noOfWithdrawls; private: // Declaring variables    float balance;...
Binary Search Tree with multiple structs? Hi, I am having an issue with trying to create...
Binary Search Tree with multiple structs? Hi, I am having an issue with trying to create a binary search tree while having multiple structs. The struct code provided is provided for us. #define CAT_NAME_LEN 25 #define APP_NAME_LEN 50 #define VERSION_LEN 10 #define UNIT_SIZE 3 struct app_info{ char category[CAT_NAME_LEN]; // name of category char app_name[APP_NAME_LEN]; // name of application char version[VERSION_LEN]; // version number float size; // size of application char units[UNIT_SIZE]; // GB or MB float price; // price in...
The program shown below reads in (N) values of time (hours, minutes, and seconds). If the...
The program shown below reads in (N) values of time (hours, minutes, and seconds). If the values for hours, minutes and seconds are a legal military time (i.e. 00 00 00 to 23 59 59) the program should display the formatted results (i.e. 12 34 56 should be displayed as 12:34:56). If there's an error for any of the entered values, an exception should be thrown and an error message should be displayed. Note, there are three exception conditions, one...