Question

array. It should use an int numEvents to keep track of how many events have been entered in the array. An event should be re

In C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note:

I have executed the code it is working fine in my local system.

Most of the senario are missing. like wether it should read from keyboard or file. can we delete any event or not. So i implemented most common one in the code. because without that code will not be possible.

if you still have some doubts that you can reach me out in comment box. i will happy to help you.

Code:

#include <iostream>
#include<string.h>
using namespace std;

   struct Date{
       int day;
       string month;
       int year;
   };
  
   struct Time{
       int hour;
       int minute;
       int second;
       bool am;
   };
  
   struct Event{
       string name;
       string description;
       string notes;
      
       Date date;
       Time time;
       bool isAppointment;
       bool active;
      
   };
int main() {
   Event event[10];
   int numEvents=0;
   int flag=0;
  
   int choice=-1;
   while(choice!=0){
       cout<<"Choice\tDescription";
       cout<<"1\tAdd new Event";
       cout<<"2\tShow Active event";
       cout<<"0\tExit\n\n";
       cout<<"enter your choice: ";
       cin>>choice;
       switch(choice){
           case 1:
           if(numEvents<10){
               cout<<"Enter Event title\n";
               event[numEvents].name;
              
               cout<<"Enter Event description\n";
               event[numEvents].description;
              
               cout<<"Add notes for Event\n";
               event[numEvents].notes;
              
               cout<<"\nEnter Date\n";
               cout<<"\tday:";
               cin>>event[numEvents].date.day;
               cout<<"\n\tmonth:";
               cin>>event[numEvents].date.month;
               cout<<"\n\tyear:";
               cin>>event[numEvents].date.year;
              
               cout<<"\nEnter Time\n";
               cout<<"\thour:";
               cin>>event[numEvents].time.hour;
               cout<<"\n\tminute:";
               cin>>event[numEvents].time.minute;
               cout<<"\n\tsecond:";
               cin>>event[numEvents].time.second;
               cout<<"\n\tam:";
               cin>>event[numEvents].time.am;
              
               cout<<"\nit is an appointment? (true/false)";
               cin>>event[numEvents].isAppointment;
              
               cout<<"\nit is active? (true/false)";
               cin>>event[numEvents].active;
               numEvents++;
           }
           else
               cout<<"Array is full, cannot add new values\n";
          
           break;
       case 2:
           flag=0;
           for(int i=0;i<numEvents;i++){
           if(event[0].active==true){
               flag=1;
               cout<<event[numEvents].name<<endl;
               }
           }
           if(flag==0){
               cout<<"No active event\n";
           }
           break;
       case 0:
           return 0;
      
       default:
           cout<<"invalid choice, please make choice again\n";
          
       }
   }
  
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
In C++ array. It should use an int numEvents' to keep track of how many events have been entered in the array. An event should be represented by a struct with several member variables. An event S...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read...

    C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics...

  • Hi! it is c++ queue simulation please read the instructions, write codes, and explain the code...

    Hi! it is c++ queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics for whatever type of system it was going...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT