Concept explainers
Day of the Year
Assuming that a year has 365 days, write a class named DayOfYear that takes an integer representing a day of the year and translates it to a string consisting of the month followed by day of the month. For example,
Day 2 would be January 2.
Day 32 would be February 1.
Day 365 would be December 31.
The constructor for the class should take as parameter an integer representing the day of the year, and the class should have a member function print ( ) that prints the day in the month-day format. The class should have an integer member variable to represent the day and should have static member variables of type string to assist in the translation from the integer format to the month-day format.
Test your class by inputting various integers representing days and printing out their representation in the month-day format.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Database Concepts (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Concepts Of Programming Languages
Digital Fundamentals (11th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- True or FalseThe same rules for naming variables apply to naming classes.arrow_forwardA(n) ____________ is one instance or variable of a class.arrow_forwardMark the following statements as true or false. The member variables of a class must be of the same type. (1) The member functions of a class must be public. (2) A class can have more than one constructor. (5) A class can have more than one destructor. (5) Both constructors and destructors can have parameters. (5)arrow_forward
- Problem Class In this exercise, you are going to create the Problem class. The Problem class is used to help simulate a math fact, for example: 2+5= Your class needs to contain two constructors, one that takes String, int, int that represents the operator sign(+,-, *, or /), the minimum, and maximum values for the number range, and a second constructor that takes only a String that represents the operator sign. For the second constructor, the minimum should default to zero and the maximum to ten. Your Problem object should generate 2 random integers between the minimum and maximum values (inclusively). Each Problem object should only have one set of numbers that do not change. While you may include additional helper methods, two methods need to be available to the user. The first is the answer method that should return a double that represents the answer to the problem. The second is the toString that should return a String that represents the problem. The format should be: number…arrow_forwardJava:arrow_forwarda. Instance of a class is called, functions have same name but different sets of parameters.arrow_forward
- In Python Programming Language : Design an Employee class that has fields for the following pieces of information : Employee name Employee number Design a class named ProductionWorker that extends the employee class. The production worker class should have fields to hold the following information: Shift number (an integer such as 1,2,3) Hourly pay rate The workday is divided into 2 shifts day and night. The shift will hold an integer value that the representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Design the appropriate accessor and getter methods for each class. Once you have designed the classes, design a program that creates an object of the production worker class and prompts the user to enter data for each object’s fields. Store the data in the object and then use the object’s accessor methods to retrieve it and display it on the screen.arrow_forwardJVarrow_forwardObject oriented programming C++ Use Classes Write a C++ program in which each flight is required to have a date of departure, a time of departure, a date of arrival and a time of arrival. Furthermore, each flight has a unique flight ID and the information whether the flight is direct or not.Create a C++ class to model a flight. (Note: Make separate classes for Date and Time and use composition).add two integer data members to the Flight class, one to store the total number of seats in the flight and the other to store the number of seats that have been reserved. Provide all standard functions in each of the Date, Time and Flight classes (Constructors, set/get methods and display methods etc.).Add a member function delayFlight(int) in the Flight class to delay the flight by the number of minutes pass as input to this function. (For simplicity, assume that delaying a flight will not change the Date). Add a member function reserveSeat(int) which reserves the number of seats passed as…arrow_forward
- Using C++, write a class that has the following properties and represents an airline flight from City A to City B. The class name must be Flight.* Flight no.it can be changed as the fleet grows (fleet information is not required for this class)* Departure city* Landing cityo take - off and landing city can be changed depending on weather conditions (weather conditions information is not required for this class)* Take-off and landing city cannot be the same* Number of passengersit depends on the reservations* Aerial view distance between two cities* Enter a method that prints flight information on the screen* Flight timeit can be changed depending on the route change (route information is not required for this class)O write the necessary methods for other variables that may change depending on themarrow_forwardngineering Computer ScienceQ&A Libraryin c++ Create a class time24, each object is a value represented the time of day in the form hours, minutes and seconds. Provide a constructor that enables an object of this class to be initialized when it is instantiated. The constructor should contain default values in case no initializes are provided. Provide Public member functions for each of the following operations: set the time, print the time, increment the time by one second, compare two times for equality, increment the time by one hour, determine if one time is “less than” (comes before) another time, and final print the time in format 12 hours. Include any additional operations that you think would be useful for your class. Design, implement, and test your class. in c++ Create a class time24, each object is a value represented the time of day in the form hours, minutes and seconds. Provide a constructor that enables an object of this class to be initialized when it is…arrow_forwardProblem: Create a Fraction class with two private positive integer member variables numerator and denominator, one constructor with two integer parameters num and den with default values 0 and 1, one display function that print out a fraction in the format numerator/denominator in the proper form such as 2/3 or ½ . Note: 2/4 should be displayed as ½.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning