Now I'm working on this, but I can't assign value. Please help me how to assign value (You don't need to care about Queue h file)
It's C++
=========================-
struct Customer
{
char id;
int arrivalTime;
int endTime;
};
int main()
{
Queue<Customer> waitLine;
waitLine.push("a", 10, 20); // i don't know how to push here.
return 0;
}
Hi,
Please go through the code for more clarity.
Note: I've used inbuilt queue from stl. U can use your own queue but logic for storing is same for both.
In your given code, you want to store customer type in queue.
Customer is a struct which contains the 3 data members.
So first you need to store the 3 data members data in structure then push that struct in queue.
Example:
waitLine.push("a", 10, 20); which is wrong
correct method: first store a,10,20 in customer variable
customer temp;
temp.id = 'a'; temp.arrivalTime = 10; temp.endTime = 20;
waitLine.push(temp);
C++ Code:
//Program starts here
#include <iostream>
#include<queue>//for queue stl, U can use your own
queue
using namespace std;
struct customer
{
char id;
int arrivalTime;
int endTime;
};
int main() {
queue<customer>waitLine;//queue with type customer
means u too store the varible of type customer
//first create varibale type customer
struct customer c;
//storing data member values in c
c.id = 'a';
c.arrivalTime = 4;
c.endTime = 5;
waitLine.push(c);//pushing in queue of type customer(c is
customer type variable)
//accessing queue
struct customer d = waitLine.front();//front of
queue
//here printing the d now not c
cout << "customer id: " << d.id << " arrival : "
<< d.arrivalTime << " departure : " << d.endTime
<< endl;
}
//End of the program


Now I'm working on this, but I can't assign value. Please help me how to assign...
I'm currently working on a problem and I'm stuck at this step --> I need to get Q to equal 504 from this equation, 0.45V = 0.53V - 0.0592/2 logQ No matter what I try I can't seem to get Q=504 as an answer for that. Please help and explain how you got it! Thank you!! ..I know the first step would be to -0.53 from both sides which gives me -0.08= -0.0592/2 logQ but then I don't know what...
So I'm not sure what I'm trying to do here. I don't understand how *adr works, I guess it's a pointer to the struct Address. How do I complete this function? And how would I have it just return the zip code or one element if I wanted to? I have two structs: struct Address { int number; // street number string street; // street Name string city; // city short zip; // zip code ...
Could someone please help me with this C language code I'm confused as to why i'm getting an error every time I run it on command line if some could please help me as soon as possible. #include <stdio.h> #include <stdlib.h> int main() { char *ptr_two = (char *)malloc(sizeof(char)*50); printf("%p\n", ptr_two); ptr_two = "A constant string in C"; printf("%p\n", ptr_two); printf("%s\n", ptr_two); free(ptr_two); return 0; }
Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...
I JUST NEED HELP WITH DISPLAY PART!
please help!
thanks in advance
// This function saves the array of structures to file. It is already implemented for you.
// You should understand how this code works so that you know how to use it for future assignments.
void save(char* fileName)
{
FILE* file;
int i;
file = fopen(fileName, "wb");
fwrite(&count, sizeof(count), 1, file);
for (i = 0; i < count; i++)
{
fwrite(list[i].name, sizeof(list[i].name), 1, file);
fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...
I need to complete the C++ program for hotel reservation. In the main cpp you have to display the hotel information from the hotel.txt based on customer preferences(which can be taken from the User.txt) For example, if the customer's budget is 200$, then only the hotels with prices below that amount should be displayed. Then the user has an option to choose which one to reserve for the particular time(which also can be found in the user.txt) The last two...
I'm creating an application with Scene Builder, I have the design of how I want the application to look like. However, I'm coding this applications in NetBeans with JavaFX FXML Application, I want to know how to take the user input that can contain integers and strings in the application and store it in a text file called "input.txt" organized into columns. "input.txt" example: ID Date StartTime EndTime StartDest EndDest Seats RD12 15Jul18 18:00 22:00 Portland Miami 64 ...And so...
Please help me figure out how to take the derivative of "Y" in
respect to "PY" of this equation. I've been trying to
figure it out for a while, but I can't figure it out.
Also, I do know that the answer is provided here. While I know
the answer I'm not quite following how they did what they did. I
think I understand how they got the first part of the answer.
However, I'm totally lost on how they...
C programming How to get rid of the below error. I do not know why is this happening and how can I correct it. Please help. typedef struct circleroute{ char* name; } Circle; Circle* circlemalloc(int nroutes); //error free Circle* readRoute(FILE* fin); //error free int main(int argc, char* argv[]){ if(argc < 2){ if(argv[1] != NULL){ FILE *fin = fopen(argv[1], "r"); if(fin == NULL){ printf("Unable to open file %s!\n", argv[1]); return EXIT_FAILURE; } int routes; fscanf(fin, "%d", &routes); Circle* c1= circlemalloc(routes); for(int...
Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the original high score program,: Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look exactly like this: Enter the name for score #1: Suzy Enter the score for...