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 {...
C++ program that Create a struct called car that has the following data members (variables): -...
C++ program that Create a struct called car that has the following data members (variables): - Color //color of the car - Model //model name of the car - Year //year the car was made - isElectric //whether the car is electric (true) or not (false) - topSpeed //top speed of the car, can be a decimal. code i have done struct not working properly. #include <iostream> using namespace std; struct Car { string color; string model_number; int year_model; bool...
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:...
can someone edit my c++ code where it will output to a file. I am currently...
can someone edit my c++ code where it will output to a file. I am currently using xcode. #include <iostream> #include <cctype> #include <cstring> #include <fstream> using namespace std; bool inputNum(int [],int&,istream&); void multiply(int[],int,int[],int,int[],int&); void print(int[],int,int,int); int main() {ifstream input; int num1[35],num2[35],len1,len2,num3[60],len3=10,i; input.open("multiplyV2.txt"); //open file if(input.fail()) //is it ok? { cout<<"file did not open please check it\n"; system("pause"); return 1; }    while(inputNum(num1,len1,input)) {inputNum(num2,len2,input); multiply(num1,len1,num2,len2,num3,len3); print(num1,len1,len3,1); print(num2,len2,len3,2); for(i=0;i<len3;i++) cout<<"-"; cout<<endl; print(num3,len3,len3,1); //cout<<len1<<" "<<len2<<" "<<len3<<endl; cout<<endl;    } system("pause"); } void...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity  ...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity   Code   Description   Project   File   Line   Suppression State Warning   C6385   Reading invalid data from 'DynamicStack': the readable size is '(unsigned int)*28+4' bytes, but '56' bytes may be read.   Here is the C++ code were I'm having the warning. // Sstack.cpp #include "SStack.h" // Constructor SStack::SStack(int cap) : Capacity(cap), used(0) {    DynamicStack = new string[Capacity]; } // Copy Constructor SStack::SStack(const SStack& s) : Capacity(s.Capacity), used(s.used)...
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 template-based class that implements a template-based implementation of Homework 3 that allows for any...
Write a template-based class that implements a template-based implementation of Homework 3 that allows for any type dynamic arrays (replace string by the template in all instances below). • The class should have: – A private member variable called dynamicArray that references a dynamic array of type string. – A private member variable called size that holds the number of entries in the array. – A default constructor that sets the dynamic array to NULL and sets size to 0....
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT