answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gladu [14]
2 years ago
11

Create a class called Date that includes three pieces of information as instance variables—a month (type int), a day (type int),

and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day, and year separated by forward slashes (/). Write a test application named DateTest that demonstrates class Date’s capabilities
Computers and Technology
1 answer:
Strike441 [17]2 years ago
3 0

Answer:

public class Date {

   private int month;

   private int day;

   private int year;

   // Constructor

   public Date(int month, int day, int year) {

       this.month = month;

       this.day = day;

       this.year = year;

   }

   //Getters and setter

   public int getMonth() {

       return month;

   }

   public void setMonth(int month) {

       this.month = month;

   }

   public int getDay() {

       return day;

   }

   public void setDay(int day) {

       this.day = day;

   }

   public int getYear() {

       return year;

   }

   public void setYear(int year) {

       this.year = year;

   }

   void displayDate(){

       System.out.println(getMonth()+"/"+getDay()+"/"+getYear());

   }

}

//Test Class

class DateTest {

   public static void main(String[] args) {

       Date dateOne = new Date(12, 25, 2019);

       dateOne.displayDate();

   }

}

Explanation:

  • Using Java programming Language
  • Create the Date class with the instance variables (Month, day and year) all of type int
  • Create the the constructor to initialize all the instance variables
  • Create getters and setters for all the instance variables
  • Create the displayDate() method which uses string concatenation along with the get() method of all the instance variables
  • Create a test class that initializes an instance of the of the Date class
  • Call the method displayDate on the instance of the class created

You might be interested in
Run a Monte Carlo simulation on this vector representing the countries of the 8 runners in this race:
ad-work [718]

Answer:

Explanation:

# Run Monte Carlo 10k

B <- 10000

results <- replicate(B, {

 winners <- sample(runners, 3)

 (winners[1] %in% "Jamaica" & winners[2] %in% "Jamaica" & winners[3] %in% "Jamaica")

})

mean(results)

4 0
2 years ago
In a well-designed detail report, a field called a(n) ____ field controls the output.
Illusion [34]

Answer:

Control

Explanation:

5 0
2 years ago
Assume that a boolean variable workedOvertime has been declared, and that another variable, hoursWorked has been declared and in
meriva

Answer:

The c++ program to show the use of Boolean variable is given below.

#include <iostream>

using namespace std;  

int main() {    

  int hoursWorked = 44;

   bool workedOvertime;        

   cout<<"This program shows the use of boolean variable." <<endl;    

   // overtime refers to working hours more than 40 hours

   if(hoursWorked > 40)

   {

       workedOvertime = true;

       cout<<"The value of boolean variable workedOvertime is true or "<<workedOvertime<<endl;

   }

   // if working hours are less than or equal to 40, overtime is not considered        

   else

   {

       workedOvertime = false;

       cout<<"The value of boolean variable workedOvertime is false or "<<workedOvertime<<endl;

   }

   return 0;

}  

OUTPUT

This program shows the use of boolean variable.

The value of boolean variable workedOvertime is true or 1  

Explanation:

This program uses a boolean variable to indicate the overtime of working hours.

The boolean variable is declared as shown.

bool workedOvertime;  

The working hours is stored in an integer variable which is declared and initialized within the program itself.

int hoursWorked = 44;

Depending on the value of working hours, the boolean variable is assigned the value true or false.  

if(hoursWorked > 40)

   {

       workedOvertime = true;

       cout<<"The value of boolean variable workedOvertime is true or "<<workedOvertime<<endl;

   }

else

   {

       workedOvertime = false;

       cout<<"The value of boolean variable workedOvertime is false or "<<workedOvertime<<endl;

   }

The value of boolean variable is displayed to the user.

In the above program, the working hours are 44 which is more than normal working hours of 40. Hence, boolean variable is assigned value true.

This program does not accept user input for working hours as stated in the question. Since value of working hours is not accepted from the user, there is no logic implemented to check the validity of the input.

This program can be tested for different values of working hours to test for the boolean variable.

8 0
2 years ago
8. In time series, which of the following cannot be predicted? A) large increases in demand B) technological trends C) seasonal
Lesechka [4]

Answer: Random fluctuations.

Explanation: Time series is a series that has all the points of time in a equal time order.So, there is usually organised and having equal gaps sequence. It can be imposed on many data  like real value data, discrete data,continuous data . But there is no space for the space of randomness so, random fluctuations are not predictable in it.Therefore the option (D) is the correct option.

6 0
2 years ago
The Open dialog box lets you _____.
galina1969 [7]
To an honest and healthy relationship
4 0
2 years ago
Other questions:
  • The Internet is BEST described as a vast _______ connection of computer networks that also link to smaller networks
    9·1 answer
  • When an author produce an index for his or her book, the first step in this process is to decide which words should go into the
    8·1 answer
  • By specifying a(n) ____ specifically for handheld devices, you can customize the page layout such as by designing the content to
    8·1 answer
  • There are two methods of enforcing the rule that only one device can transmit. In the centralized method, one station is in cont
    5·1 answer
  • Some numbers are formed with closed paths. the digits 0, 4, 6 and 9 each have 1 closed path and 8 has 2. None of the other numbe
    6·1 answer
  • we are given an array a consisting of n distinct integers. we would like to sort array A into ascending order using a simple alg
    8·1 answer
  • Assume that the variables v, w, x, y, and z are stored in memory locations 200, 201, 202, 203, and 204, respectively.
    6·1 answer
  • Referential integrity constraints are concerned with checking INSERT and UPDATE operations that affect the parent child relation
    5·1 answer
  • A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
    10·1 answer
  • In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!