Question

You are given 102_Lab4.cpp. Please DO NOT change main function

You are given 102_Lab4.cpp. Please DO NOT change main function, but will only use it during development of your Date and Person classes. You need to complete class definitions in same cpp file and will submit the completed file. 

Sample Input:Sample Output:

 4 5 2000 

Burak 

12 6 1994

Burak: Appointment Day:4.5.2000 1276/1994

   Notes: Please check the sample input/output files with your main function (in 120_Lab4.cpp) before starting your implementation. 


  Testing: We provide a sample input/output text file pairs for you to test your codes at Ubuntu. We recommend you to use input redirection mechanism of your operating system to test your programs. For example, if your executable is called as Lab4, redirect the input.txt file to standard input using < operator and redirect your outputs to a file using > operator such as: 

> ./Lab4<input.txt>output.txt 


This kind of execution enables your programs to read inputs from a file without writing any file related functions. In other words, cin reads data from the redirected files instead of the std. input in this way (e.g. keyboard).


image.png

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

Step 1 : Save the following code in person.h

#include
#include

class Date
{
private:
   int day;
   int month;
   int year;
public:
   Date(int d, int m, int y) {
       day = d;
       month = m;
       year = y;
   }
   Date() {
       std::cin >> day >> month >> year;
   }
   void printDate2() {
       std::cout << day << "/" << month << "/" << year << "\n";
   }
   int getDay() {
       return day;
   }
   int getMonth() {
       return month;
   }
   int getYear() {
       return year;
   }
};

class Person
{
private:
   std::string name;
   Date doa;
public:
   Person(std::string nam, Date dat) {
       name = nam;
       doa = dat;
   }
   void prinInfo() {
       std::cout << name << ": Appointment Day:";
       std::cout << doa.getDay() << "." << doa.getMonth() << "." << doa.getYear() << "\n";
   }
};

Step 2 : Save the following code in Lab4.cpp

#include
#include
#include "person.h"
using namespace std;

int main() {
int d, m, y;
string s;
cin >> d >> m >> y;
cin >> s;
Date d1(d, m, y);
Date d2;
Person p(s, d1);
p.prinInfo();
d2.printDate2();
return 0;
}

Step 3 : Save the following lines in input.txt

4 5 2000
Burak

12/6/1994

Step 4 : Compile the program and run ./Lab4 < input.txt > output.txt

Following lines will be written to output.txt

Burak: Appointment Day:4.5.2000
12/6/1994

Add a comment
Know the answer?
Add Answer to:
You are given 102_Lab4.cpp. Please DO NOT change main function
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
  • Write a C program which computes the count of the prime and perfect numbers within a...

    Write a C program which computes the count of the prime and perfect numbers within a given limit Land U, representing the lower and upper limit respectively. Prime numbers are numbers that have only 2 factors: 1 and themselves (1 is not prime). An integer number is said to be perfect number if its factors, including 1 (but not the number itself), sum to the number. Sample Inputi: 1 100 Sample Outputs: Prime: 25 Perfect: 2 Sample Input2: 101 10000...

  • hi, please help in c++. I dont understand how to do this, and a lot of...

    hi, please help in c++. I dont understand how to do this, and a lot of the ways on the internet is confusing me, i am a beginner. with all steps and explantions, will rate! Write a program that determines the frequency of each char in an input file. Your program should . read in an unknown number of chars from an input file named input.txt, • using a function written by you, determine the frequency of occurrence of each...

  • Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator...

    Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator Overloading – Chapter 14 Design a class Complex for representing complex numbers and the write overloaded operators for adding, subtracting, multiplying and dividing 2 complex numbers. Also create a function that will print a complex number on the screen. Provide appropriate constructors...

  • Write a function template that receives a priority queue and an output stream as parameters. Lab 48 Due Date: See Blackboard Source File: /2336/48/1ab48.cpp Input: Output:under control of main functio...

    Write a function template that receives a priority queue and an output stream as parameters. Lab 48 Due Date: See Blackboard Source File: /2336/48/1ab48.cpp Input: Output:under control of main function Waol under control of main function Write a function template that receives a priority queue and an output stream as parameters. The function determines the distribution of the elements in the priority queue; that is, the function counts the number of occurrences of each element. The format of the output...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • python Create a program to open a text file for reading, find the maximum number in...

    python Create a program to open a text file for reading, find the maximum number in the file, determine if that maximum number is even, and write to an output text file. You should either write Yes if the number is even, otherwise write the maximum number. You should note the following: • Your input file must be named input.txt • The input file has one integer number per line • Your output file must be named output.txt • Your...

  • Do not change anything in the supplied code below that will be the Ch12_Ex9.cpp except to...

    Do not change anything in the supplied code below that will be the Ch12_Ex9.cpp except to add documentation and your name. Please use the file names listed below since your file will have the following components: Ch12_Ex9.cpp given file //Data: 18 42 78 22 42 5 42 57 #include <iostream> #include "unorderedArrayListType.h" using namespace std; int main() { unorderedArrayListType intList(25);     int number;     cout << "Enter 8 integers: ";     for (int count = 0; count < 8; count++)...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code...

    ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code after the comments in the main method and using the javadoc documentation to implement the other methods. Task 1: Send array data to the screen In ArraysAndFiles.java, create a new method printOnScreen and compile it. In the main method of ArraysAndFiles.java, add the code to declare and initialize the array of Strings and call printOnScreen to print the array on the screen. Task 2:...

  • [15 marks] Suppose that students enrolled in one course are required to take four tests, and...

    [15 marks] Suppose that students enrolled in one course are required to take four tests, and each student’s final grade for this course is the average of his/her grades of these four tests. This question asks you to write a program that can be used to compute the lowest final grade, highest final grade and the average final grade. General Requirements: Use a5q1.c as the name of your C source code file. We will use the following command on bluenose...

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