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...
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 =...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in airplane const int COLS = 4; void menu(); //displays options void displaySeats(char[][COLS]); void reserveSeat(char [ROWS][COLS]); int main() { int number=0; //holder variable char seatChar[ROWS][COLS]; for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLS; j++) { seatChar[i][j] = '-'; } } int choice; //input from menu bool repeat = true; //needed for switch loop while (repeat...
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 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:...
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)...
Hello, I feel like I am super close but I can not figure out why my...
Hello, I feel like I am super close but I can not figure out why my C++ code it not displaying the proper medium. Thank you! Here is an example of the output: Input : a[] = {1, 3, 4, 2, 6, 5, 8, 7} Output : Mean = 4.5 Median = 4.5 Code so far:   #include <iostream> using namespace std; int main() { int a[100]; int n,i,sum=0; float mean, medium; //read array size // read array cout<<"Enter array size:...
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;...
C++ Fix my code This code is for imitating the round robin cpu scheduling algorithim using...
C++ Fix my code This code is for imitating the round robin cpu scheduling algorithim using linked lists. Currently I am able to input processes and store / display them properly. The issue begins somewhere after I have displayed the processlist (I get a segmentation fault (core dumped) or the code doesnt seem to run). I have marked the location of where I think the issue begins with a comment. Please fix the code so that it is working properly....