C/C++ :: Email Simulation Using Queue?
Feb 1, 2015
Here is the assignment I get:
Write an email simulator that processes mail at an average of 40 messages per minute. As messages are received, they are placed in a queue.assume that the messages arrive at an average rate of 30 messages per minute.messages must arrive randomly.
Each minute, you can dequeue up to 40 messages and send them. Assume that 25% of the messages in the queue cannot be sent in any processing cycle.use a random number to determine whether a given message can be sent. If it can't be sent, enqueue it.
Run the simulation for 24 hours, At the end of the simulation, print the statistics that show:
-The total messages processed.
-The average arrival rate.
-The average number of messages sent per minute.
-The average number of messages in queue in a minute.
-The number of messages sent on the first attempt, the number sent on the second attempt, and so forth.
-The average number of times messages had to be requeued (do not include the messages sent the first time in this average)
Well, actually I've done a part of the coding. But how to continue it. And here is my code :
#include <iostream>
using namespace std;
#define SIZE 40
class Queue {
int queue[SIZE];
int head, tail;
public:
Queue();
void Enq(int num);
[code]....
View 1 Replies
ADVERTISEMENT
Feb 20, 2013
I have a paradigm in a loop of queues of a vector,if a condition is true,increase sizes of the queue of that particular queue in the loop of queues, if condition is false, the queuesize is left as such in loop of queues. After this operation i need to search the queue sizes of all queues and enqueue in the shortest queue.
I want to do something like the code given below
#include <vector>
#include <queue>
int min_index = 0;
std::vector<std::queue<int> > q
std::size_t size = q.size();
[Code] ....
How to implement this logic?
will q[i].size=q[i].size+5 increase the queuesize by 5 for the ith queue?
View 12 Replies
View Related
Nov 24, 2014
I have to write a program to take packets of information destined for certain ports then provide the current message using the packets I've gotten so far. Packets can come out of order, so when asked for the message, packets that haven't arrived yet are skipped and the next packet is appended. After giving the message, I have to delete all the current packets as well as ones that are received late, after the packets that were supposed come after the late packet were already provided in the message.
Data:Up to 1000 ports, numbered 0-64000, and each message can contain up to 1000 packets.
View 2 Replies
View Related
Sep 26, 2014
how to write a "charge simulation method" program in C or C++? It's to calculate electric distribution and also electric potential of two different dielectrics. I have attached the diagram of the shape of the electrode that needs to be investigated.
View 1 Replies
View Related
Jan 25, 2013
My Project is to Dynamically Link 2 Software for Co-simulation n C/C++. So that Output of One Software becomes Input of Other automatically . at present we input the parameters manually in both the software . what to do so that it pick up values itself and gives the output by solving each and everything at once in both the software .
View 5 Replies
View Related
Jan 23, 2013
I have to simulate flash memory using C++ for a project.
View 2 Replies
View Related
Oct 30, 2013
I'm trying to create program that reads in commands from an input file, and accordingly creates, connects or destroys logic gate primitives (and gates, or gates). Additionally, I'm trying to modify a previous program that I wrote to do this using QThreads, where each gate is placed in its own QThread. I'm trying to avoid using invokemethod, and I'm sure this method can work. My specific issue that I'm having trouble debugging is in my connect code block in main.cpp. Whenever I try to reference a gate specified by the input file that is NOT the true or false gate (I have one of each and they are attached to any gate that needs a true or false input), I get only a NULL reference. This includes attempting to reference the gate in my gatelist QMap. Calling gatelist.value(newCommand.at(1)) causes the program to hang, and the connect statements referencing said gate return errors about connecting a signal or slot of a NULL pointer.
Here is main.cpp:
#include <QPointer>
#include <QMap>
#include <QDebug>
#include <QString>
#include <QFile>
#include <QTextStream>
[Code] ...
My accompanying class declarations can be found here : [URL] ....
View 6 Replies
View Related
Feb 11, 2013
How do i define user and lottery..
//Declarations
#include <iostream>
#include <cstdlib>
#include <ctime>
const int lotteryDigits = 10;
const int SIZE = 5;
const int Power = 1;
int generateLottery(int[], int, int);
[Code] ....
View 15 Replies
View Related
Feb 17, 2014
Anyhow, I have a program due Wednesday that is along the lines of the classic Bank Teller simulation using Queue's.
Unlike most of these programs, I have to integrate my own Queue, QueueNode, Teller, and Customer classes. I have attached all of these headers below plus the main file.
Now the error: While I'm sure there are other issues with the code, it will not let me create a new customerQueue (of Queue type) object as such:
Queue<Customer> customerQueue;
The error it is giving me is:
no matching constructor for initialization of 'Queue<Customer>'
Here is my code:
Queue.h:
#ifndef QUEUE2_H_
#define QUEUE2_H_
#include <iostream>
#include "Teller.h"
#include "Queue.h"
[Code] ....
View 1 Replies
View Related
Apr 25, 2013
I'm currently working on a simulation of the motion of magnets on a rod. As part of it, there are arrays of the properties of the magnets:
long double *accelerations; // These will later be dynamically allocated depending on the number
long double *velocities; // of magnets
long double *positions;
However, when I go to compile this, the compiler gives me these error for the pointers:
error: two or more data types in declaration of 'accelerations'
error: two or more data types in declaration of 'velocities'
error: two or more data types in declaration of 'positions'
Apparently, the compiler isn't recognising long double* as a type and is instead reading is as the two types long and double*.
My compiler is MinGW 4.4.3
View 4 Replies
View Related
Sep 5, 2014
I'm supposed to build a banking simulation program around the BankAcct class, which provides the following service: create new account with unique account number (maximum 5 accounts created in a single test running); deposit/withdraw; print information of all existing account. I was running a test program with only 2 services first, namely creating new account and depositing, but the program just keep on crashing and I couldn't figure out why.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
[Code].....
View 1 Replies
View Related
Apr 26, 2015
I am trying to add an attachment to an email in c#. I've managed to send the email with the subject, body and everything just fine. When it comes to adding an attachment it just wont attach and will send me the email without it.
This is the code I've used for adding the attachment
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(@"C:UsersWilliamPicturesa.TXT");
MyMailMessage.Attachments.Add(attachment);
The only thing i can think of thats wrong with it is the file path even though i tried multiple paths, formats, using \ instead of @ so i just dont know.
View 3 Replies
View Related
Dec 29, 2014
If I wanted to learn about how to create an email server from scratch using C++ where would I go online. I am probably in way over my head but I figured I would give it a try anyway and see how things go.
View 4 Replies
View Related
Apr 14, 2014
How to email a simple file like .txt .pdf etc... I can't find any codes that work ....
View 1 Replies
View Related
Jul 13, 2013
Now I have to write a code which would determine whether an Email address is valid or not.
In my exercise a valid address should look like this : ___@___.___.il (___ for any letters)
E.g. Valid address:
something @ something . something . il Invalid: tami @ jce . ac . uk
(without spaces of course)
Code:
#include <iostream>
#include <string.h>
using namespace std;
int isValid (char s[]) {
int length=strlen(s), ind1=0, ind2=0;
[Code] ....
It doesn't work well. It says both addresses are wrong when the 1st one isn't.
View 9 Replies
View Related
Dec 11, 2013
writing a program for "Validating the e-mail id without using regular expressions in c/c++"?
View 4 Replies
View Related
Feb 26, 2015
I am new to C++ and programming in general. I was wondering if it is possible to use C++ to search for company email formats and domain addresses?
For example, finding the correct format like:
jsmith@carnival.com
or
johnsmith@carnival.com
or
j.smith@carnival.com
Also, if it is possible to find the actual email domain, such as:
@carnival.com
or
@carnivalcruises.com
or
@carnivalcorp.com
View 4 Replies
View Related
Dec 10, 2014
My first question is:
What are good/bad practices of creating an email scraper? The last thing I want to do is piss people off. Are there any laws/regulations that my program should conform to?
The second question:
It's easy to fetch a list of emails from a website/document.. But what if I wanted to associate something like a Name, an Address, and a Phone Number? I'm sure I could use RegEx to extract all of that info no problem, but how do I know which email to associate the Name, Address, and Phone number with? Is that even possible?
I'm trying to create this for my marketing team. We get hundreds of PDF documents sent to us per month, all containing lists of client emails and contact information. We also get directed to company staff directory websites a lot, and would like to be able to extract the information from them without having to copy/paste each element in the list, which is how my company is doing it now. We'd much rather be able to click a button and have a program automate these tasks for us.
View 7 Replies
View Related
Jan 2, 2014
I want to send an email using Google's SMTP server. How do I achieve it?
View 2 Replies
View Related
Jun 4, 2014
Ii made one string variable and called it email_confirm. I used cin to get the users email but i don't know to check if the email is real.(without being connected to the internet).
For example,in PHP you can use ereg() or eregi() to see if the email is real, I mean you can see how many characters the email_confirm is made off or how many characters is used after the @ or . is used. is there any functions for this?
View 5 Replies
View Related
Jan 26, 2013
I have struggled to send email from my MFC applications using severl methods:
1) http via my server - works but limited
2) M$ Outlook automation - works but not easily interchangeable between machines
3) Windows Sockets - available information simply too complicated
4) Purchase an ActiveX control - I hate black box solutions and am too cheap
I have looked at P. J. Naughter's class
CPJNSMTPConnection v2.99
An MFC class to encapsulate the SMTP protocol
[URL]
This approach requires the implementation of OpenSSL which turns out to be nothing short of a nightmare to install (so I never got it to run). I am looking for an example of an application that utilizes SMTP via Windows sockets api.
View 6 Replies
View Related
Oct 4, 2013
I am currently working on a MFC application and need to send (non-document) files created by the program over email. (either with SMTP client on the machine or web mail)
I have searched the web and some forum and cannot find a code that work. They either have errors, or not Unicode compliant, even when converted they still don't work.
Everything code example seems to use MAPI, but like I said non of them worked.
see here
[URL]
A simpler approach would be to modify or override the event handler OnFileSendMail() that is built into MFC document view framework and use the menu id ID_FILE_SENDMAIL.
To get this feature all you have to do is give any menu item the resource id ID_FILE_SENDMAIL and MFC will call the installed mail client for you. The problem is MFC will attach any open document that is in focus when you select the menu item. The file that I wish to send is not associated with the document so I was wondering if there is a way to find the OnFileSendMail() handler and modify it to send my file instead. I am not too keen on how MFC route command handler such as ID_FILE_NEW, ID_FILE_SENDMAIL etc. These methods/functions are hidden from view or I don't know where to find them.
View 5 Replies
View Related
Nov 11, 2013
I have outlook 2007 and i am building a plugin, that will edit the footer for all the email attachments,(for example - abc confidential). How can i write an outlook addin, that will on the fly, will check for excelsheets and word documents and edit their footer with "abc confidential"
View 1 Replies
View Related
Jan 19, 2014
I have almost a hundred names in a text file that I want to convert to email addresses and save to another file. I seem to have it working, but it doesn't print the full names in the email prefix. The output I'm looking for is Doe_John@livebrandm, but I'm only getting D_J@livebrandm. I'm not sure what I should specifically be reading up on that applies to this directly.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fpin=fopen("namesIN.txt", "r");
FILE *fpout=fopen("emailOUT.txt", "a");
char first[20],last[20],inbuff[1500];
[Code]...
View 9 Replies
View Related
Nov 28, 2014
How to build a FiFO queue without using the STL (done that no problem), get it to dequeue (again, done that no problem). However, to get those extra marks, I need to be able to order it using a priority system.
I've tried ordering the NodeDequeue class that I'll show at the bottom of this post, but I just cannot get it to order appropriately. The closest I have got is everything in order but I lose a Node from the memory completely. So, that's no good.
The most logical idea I have thought of right now is to send the largest number to the back of the queue each time it's iterated, eventually, the largest number will end up at the front.
class PriorityQueue : public Queue {
public:
Node* NodeDequeue(void) {
Node* tmp = front;
Node* seek = tmp->getPrev();
[Code] .....
View 3 Replies
View Related
Aug 17, 2014
I'm having a problem with removing an item from a queue. At first in the debugger I got SIGTRAP but I don't get it anymore but the problem still exists. When you try to remove an item from the queue the first nothing happens. Here's the code below compile it and you see what I'm talking about.
Code:
#include <stdio.h>
#include <stdlib.h>
struct Node {
char let;
struct Node *nextNode;
};
[code]....
View 12 Replies
View Related