C++ TrainStation Program
Create a function called searchForSchedules that will:
- prompt a user to enter a scheduleId
- search for arrival and departure times of trains based on a trains ID number
Create a function called editSchedules that will:
- allow the user to edit the fields for a given schedule that is in the linked list.
- the program must prompt the user to enter the scheduleId as the key to find the schedule to edit. Print a message if the schedule is not found in the linked list.
- for simplicity, the program may re-prompt the user to re-enter all of the fields associated with the given schedule; however, it must reuse the scheduleId value
#include<iostream>
#include<string.h>
#include<iomanip>
#include<fstream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
class TrainStation
{
struct Railway
{
char Train_id[12];
char dept_time[12];
char Arrival_time[12];
struct Railway *next;
};
struct Railway *temp1;
//struct Railway Record[10];
struct Railway *swapping;
public:
void write_to_Notice()
{
char tempstr[100];
char ch;
do
{
memset(tempstr,0,sizeof(tempstr));
temp1 = (struct Railway*)malloc(sizeof(struct Railway));
cout<<"Enter Train Id Number "<<endl;
cin>>tempstr;
strcpy(temp1->Train_id,tempstr);
memset(tempstr,0,sizeof(tempstr));
cout<<"Enter Departure Time Of Train: "<<endl;
cin>>tempstr;
strcpy(temp1->dept_time,tempstr);
memset(tempstr,0,sizeof(tempstr));
cout<<" Enter Arrival Time of Train "<<endl;
cin>>tempstr;
strcpy(temp1->Arrival_time,tempstr);
temp1->next=swapping;
swapping=temp1;
cout<<"Do you want to Record one
more.Press y to continue:"<<endl;
cin>>ch;
}while(ch=='y'||ch=='Y');
cout<<"Stopped to give input data:"<<endl;
}
public:
int searchForSchedules(char
str[])
{
struct Railway
*temp;
temp=temp1;
while(temp!=NULL)
{
if(strcmp(temp->Train_id,str)==0)
{
cout<<"The Details are
found:"<<endl;
cout<<"The Train
Departure Time is:"<<temp->dept_time<<endl;
cout<<"The Train
Arrival Time "<<temp->Arrival_time<<endl;
return 0;
}
temp=temp->next;
}
return -1;
}
public:
void
display()
{
struct Railway
*temp3;
temp3=temp1;
cout<<"Train
id:"<<"\t"<<"Group Time"<<"\t"<<"Departure
Time"<<endl;
if(temp3!=NULL)
{
while(temp3!=NULL)
{
cout<<"\t"<<temp3->Train_id<<"\t"<<temp3->dept_time<<"\t"<<temp3->Arrival_time<<endl;
temp3=temp3->next;
}
}
}
};
int main()
{
TrainStation obj;
char key[12];
cout<<"Read The Trains Information
Details:"<<endl;
obj.write_to_Notice();
cout<<"Please Enter The Train id
Number"<<endl;
cin>>key;
int result=obj.searchForSchedules(key);
if(result==-1)
printf("The Given Schedule Id Not Found in Notice:\n");
//obj.display();
return 0;
}
C++ TrainStation Program Create a function called searchForSchedules that will: - prompt a user to enter...
Division by Zero Problem: Create a program titled Division. Have the program prompt the user "Enter numerator and denominator" and store the two values entered. (If you wish the user to "Enter numerator/denominator" be sure to adjust your data gathering variables to include a holder variable for the slash character.) Include a function titled Quotient that takes 2 integers as input and provides the quotient of the 2 integers as integer output. (The remainder is truncated. Thus, 5/3 will be...
Create a C program, which writes a prompt that asks a user to enter average daily temperature information for two cities. One prompt should request the city name, and the other prompt should request the average daily temperature. Store the data received in two arrays (one for temperature and one for city).
Write a C++ Program. you were required to first create a function called average. The return type is double and it takes in two parameters, one of type string the other of type double. In the average function write a for loop that PROMPT THE USER to enter in a grade 5 times, keep a sum of all the different grades then return the average of the grades. (sum / 5) Next write a function of type double called lowest...
C++ Program Help Prompt your user to enter a length of a word to search from a string. Use forking to spawn a child process to perform the counting task. Allow the child process to finish and output the number of words found (if any), before prompting the user for the next length. Count all words in the string with this length and output the number of words that correspond to this length. Program keeps asking user for length till...
Write a program that will create an array of ten integers, allow the user to enter those integers, and eventually search through the array based on index position: 1. Declare the array. You cannot assign elements to an array until it has first been created. 2. Next, run a for loop so that the user can enter an integer to save in each index position of the array. Since you this array holds ten elements , the index position starts...
Write a "PYTHON" program to prompt the user to enter a fist name, last name, student ID and GPA. Create a dictionary with the data. Print out the data. Then remove the GPA and print again.
Prompt the user to enter two character strings. The program will then create a new string which has the string that appears second, alphabetically, appended to the end of the string that shows up first alphabetically. Use a dash (-') to separate the two strings. You must implement the function string appendStrings(string, string), where the return value is the combined string. Display the newly created string. Your program must be able to handle both uppercase and lowercase characters. You are...
The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...
Can
you help me to create this program, please?
Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...
c++ Write a program that prompts the user to enter a length in feet and then enter a length in inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Your error message should read A non positive number is entered and allow the user to try again.