C++ please
Let's pretend that we can still go out to eat at a restaurant. Suppose we have the job to make a program that accepts a dinner reservation. The information collected will be the name of the customer, the date for the reservation, the time for the reservation (good choice for a hierarchical struct), the number in the party, email address (for updates) and phone number. Define a hierarchical structure for a dinner reservation that will contain the above information. Using that structure declare variables for at least two dinner reservations. Write a program that accepts data, populates the variables and prints out the data for at least two reservations. You can modify the functions from this module to read the data and print the data. (NOTE: Editing the program we just did should make this pretty easy.)
Here are the functions and code from the module:
// // Examples of hierarchical structures and functions // #include <iostream> #include <fstream> #include <iomanip> #include <string> using namespace std; 1. Define the structure for date. It has to be defined prior to the structure that uses it.
struct date
{
unsigned int month;
unsigned int day;
unsigned int year;
};
2. We will now make a modified version of the student_record structure by adding
a member for the birthdate. (I have also removed the enumeration type from the struct
and changed the type for exam and homework to double.) The birthdate can be inserted at
any location within student_record. Remember that the order of struct members does not matter.
Here is the modified student_record.
struct student_record
{
string firstname;
string lastname;
date birthdate;
float gpa;
double exam;
double homework;
float grade;
};
// Function Prototypes go Here
int main(void)
{
3. Declare some variables of type student_record. Let's use Alice and Bob again. Notice
that we cannot initialize these variables right now since they continue multiple items of
different types.
// Variables of type student record
student_record Alice, Bob;
4. Let's populate the members of Alice by typing in the data. The names are easily
entered just as in our previous example.
cout << "Enter Student Data for Alice." << endl;
cout << "First Name " << endl;
cin >> Alice.firstname;
cout << "Last Name " << endl;
cin >> Alice.lastname;
5. Now for birthdate. How do we handle the hierarchical structure? We have to use another dot.
cout << "Enter birthdate as MM DD YYYY " << endl;
cin >> Alice.birthdate.month >> Alice.birthdate.day >> Alice.birthdate.year;
6. When the birthdate is entered we have to access each of the three members (month, day
and year) individually. First we get Alice's birthdate using one dot (Alice.birthdate) .
In order to "drill down" to the individual parts of the birthdate we have to use an
additional dot (Alice.birthdate.month).
7. Now let's fill out the remaining data for Alice.
cout << "Enter gpa " << endl;
cin >> Alice.gpa;
cout << "Enter exam average " << endl;
cin >> Alice.exam;
cout << "Enter homework average " << Alice.homework;
cin >> Alice.homework;
8. Compute Alice's numeric grade from exam and average
Alice.grade = Alice.exam * 0.8 + Alice.homework * 0.2;
9. Finally let's print out all of Alice's data.
cout << endl;
cout << "Data Record for Alice " << endl;
cout << Alice.firstname << " " << Alice.lastname << endl;
cout << "Birthdate: " << Alice.birthdate.month
<< setw(3) << Alice.birthdate.day
<< setw(5) << Alice.birthdate.year << endl;
cout << fixed << setprecision(1);
cout << "Grade Point Average " << Alice.gpa << endl;
cout << "Exam Avg. " << Alice.exam << endl;
cout << "Homework avg. " << Alice.homework << endl;
cout << "Grade " << Alice.grade << endl;
cout << endl << endl;
system("pause");
return 0;
}
10. This completes the example. You should compile and run the program entering data for Alice. We will get to Bob later. Proceed to the next page where we will introduce functions.
CODE :
#include<iostream>
using namespace std;
//This is user defined data type
called "struct"
struct restro{
char name[30];
int date;
int time;
int number;
char email[30];
int phn_number;
};
int main(){
//Array of objects
restro r[100];
int n;
cout<<"Enter the reservations you want to make
:";
cin>>n;
cout<<"Please Enter the Details";
//loop for taking
input
for(int i=0;i<n;i++){
cout<<"\nReservation
"<<i+1<<endl;
cout<<"======================================================\n";
cout<<"Enter the name
:";
cin>>r[i].name;
cout<<"\nEnter the date of
reservation : ";
cin>>r[i].date;
cout<<"\nEnter the time of
reservation : ";
cin>>r[i].time;
cout<<"\nEnter the number :
";
cin>>r[i].number;
cout<<"\nEnter Email :
";
cin>>r[i].email;
cout<<"\nEnter your phone
number : ";
cin>>r[i].phn_number;
cout<<"======================================================\n";
}
cout<<"\n\nDetails of the Reservation";
//loop for the output
for(int i=0;i<n;i++){
cout<<"\nReservation
"<<i+1<<endl;
cout<<"======================================================\n";
cout<<"Name
:"<<r[i].name;
cout<<"\nDate of reservation
: "<<r[i].date;
cout<<"\nTime of reservation
: "<<r[i].time;
cout<<"\nNumber :
"<<r[i].number;
cout<<"\nEmail :
"<<r[i].email;
cout<<"\nYour phone number :
"<<r[i].phn_number;
cout<<"\n======================================================\n";
}
}
C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose...
(C++) I need to alter the code below to fit the given requirements. You will need to move the calculations to a function. A second function to return the Letter Grade. You will need to define a namespace to contain the CONST. Also, need to define an enum for letter grades: A, B, C, D, and F. Console Student Grade Calculation Form First Name: Larry Last Name: Hobbs Homework Average: 65 Midterm Grade: 90 Final Exam Grade: 75 Student: Larry...
Need done in C++ Can not get my code to properly display output. Instructions below. The code compiles but output is very off. Write a program that scores the following data about a soccer player in a structure: Player’s Name Player’s Number Points Scored by Player The program should keep an array of 12 of these structures. Each element is for a different player on a team. When the program runs, it should ask the user...
I need this done in C++ Can someone help me get my code from crashing. The code compiles but it can be easily crashed with user input. The rubric and code below Instructions: Write a program that scores the following data about a soccer player in a structure: Player’s Name Player’s Number Points Scored by Player The program should keep an array of 12 of these structures. Each element is for a different player on a...
Objectives: The main objective of this assignment is checking students’ ability to implement membership functions. After completing this assignment, students will be able to: implement member functions convert a member function into a standalone function convert a standalone function into a member function call member functions implement constructors use structs for function overloading Problem description: In this assignment, we will revisit Assignment #1. Mary has now created a small commercial library and has managed...
Objectives: The main objective of this assignment is checking students’ ability to implement membership functions. After completing this assignment, students will be able to: implement member functions convert a member function into a standalone function convert a standalone function into a member function call member functions implement constructors use structs for function overloading Problem description: In this assignment, we will revisit Assignment #1. Mary has now created a small commercial library and has managed...
-can you change the program that I attached to make 3 file
songmain.cpp , song.cpp , and song.h
-I attached my program and the example out put.
-Must use Cstring not string
-Use strcpy
- use strcpy when you use Cstring: instead of this->name=name
.... use strcpy ( this->name, name)
- the readdata, printalltasks, printtasksindaterange,
complitetasks, addtasks must be in the Taskmain.cpp
- I also attached some requirements below as a picture
#include <iostream>
#include <iomanip>
#include <cstring>
#include <fstream>...
please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...
IN C++ PLEASE -------Add code to sort the bowlers. You have to sort their parallel data also. Print the sorted bowlers and all their info . You can use a bubble sort or a shell sort. Make sure to adjust your code depending on whether or not you put data starting in row zero or row one. Sort by Average across, lowest to highest. The highest average should then be on the last row.. When you sort the average, you...
In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits> #include <iostream> #include <string> // atoi #include <time.h> #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ const unsigned int DEFAULT_SIZE = 179; // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() {...
can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...