1answer.
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
den301095 [7]
3 years ago
13

Write a program that reads in the following data, all entered on one line with at least one space separating them: a) an integer

representing a month b) an integer representing the day of the month c) an integer representing a year 1. Check that the month is between 1 and 12. If it’s not print an error message. 2. Day cannot be 0 or less nor can it be more than 31 for all months. Print an error message if these conditions occur. If day is in the range of 0 and 31, you will still need to check other conditions as noted below in 4. 3. Year cannot be less than 1. Print an error message if that occurs. If any one of these three conditions occurs, only one error message should print and no further code should be executed. If everything is good so far, then continue as below: 4. Check that day is correct for the month. Remember the poem "30 days has September, April, June and November, All the rest have 31 except February which has 28 but in a leap year has 29"
Computers and Technology
1 answer:
Rina8888 [55]3 years ago
4 0

Answer:

import java.util.Scanner;

public class DataConstraint {

public static void main(String[] args) {

System.out.print("Enter month, day, year separated by spaces :");

Scanner sc=new Scanner(System.in);

int M,D,Y;

M=sc.nextInt();

D=sc.nextInt();

Y=sc.nextInt();

if(1<=M && M<=12 && 1<=D && D<=31 && Y>=1)

{

if(M==4 || M==6 ||M==9 || M==11){

if(D==31) {

System.out.println("month "+M+" can not have more than 30 days");

System.exit(0);

}

}

else if(M==2)

{

if((Y%400==0) || (Y%4==0 && Y%100!=0)) {

if(D>=30) {

System.out.println("month "+M+" cannot have "+D+" days");

System.exit(0);

}

}

else {

if(D>=29) {

System.out.println(Y+" is not a leap year, "+D+" is invalid");

System.exit(0);

}

}

}

System.out.println(M+" "+D+" "+Y+" is a valid date");

}

else{

if(1>=M || M>=12) System.out.println(M+" is not a valid month");

if(1>=D || D>=31) System.out.println(D+" is not a valid date");

if(Y<1) System.out.println("year can not be negative");

}

}

}

Explanation:

  • Use a conditional statement to check the month is between 1 and 12.
  • Check that the date is between 1 and 31 and year must be positive value.
  • If no. of days are more than 29, then the year cannot be a leap year.

You might be interested in
You would like to create a graph that shows how much of your total investments are in stocks, savings, and mutual funds. You sho
sdas [7]
The answer is D. line graph
4 0
3 years ago
Read 2 more answers
The communication channel used in IMC must rev: 12_06_2018_QC_ CDR-223 Multiple Choice match the traditional channel used in tha
Setler [38]

Answer:

connect the sender with the desired recipients.

Explanation:

Integrated Marketing Communication (IMC) is a process through which organizations create seamless branding and coordination of their marketing and communication objectives with its business goals and target audience or consumers. The communication tools used in IMC are both digital and traditional media such as billboards, search engine optimization, magazines, television, blog, radio, webinars etc.

The communication channel used in IMC must connect the sender with the desired recipients.

The receiver is any individual who is able to read, hear or see and process the message being sent or communicated in the IMC communication process. Any interference the IMC communication process is known as noise.

An organization can analyze and measure the effectiveness of the IMC communication process by considering market share, sales, and customer loyalty.

5 0
3 years ago
What best describes "broadband access"?
Andre45 [30]

Answer:

The Correct option is : d. BROADBAND ACCESS enable users to connect to a high speed networks

Explanation:

As the names implies BROADBAND ACCESS can be defined as a technology that enables users to have the access to fast and high speed internet connection when browsing, streaming or downloading reason been that BROADBAND ACCESS is more faster and quicker which inturn enables the user to do a lot more on the internet which is why BROADBAND ACCESS is often refer or known as a high and fast speed Internet access connection.

5 0
3 years ago
Consider a computer system, where each processor can independently perform a separate task. given that the response time on a co
vekshin1
First four tasks = 8 seconds
Next four tasks = 8 seconds
Last two tasks = 8 seconds

The total number of seconds to perform all tasks is 24 seconds.

The throughput, which would be the number of tasks per second, is calculated by taking the number of tasks and dividing by the number of seconds:

10 tasks / 24 seconds = 5/12 or 0.4167 tasks per second
8 0
3 years ago
Identify the three fuzzy logic systems in the given text.
Furkat [3]

Answer:

she is the both city CAA been Van from is next

4 0
2 years ago
Other questions:
  • Which wildcat character will return a single character when using the find dialog box
    14·1 answer
  • You are configuring IP settings on a new network. For the external interfaces, you decide to obtain registered IP addresses from
    5·1 answer
  • Which of the following is no longer necessary when you use HTML5 to develop Webpages? Please Hurry This Is For An Assignment due
    13·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Read the following sentence from an argumentative essay.
    11·1 answer
  • Experienced students may serve as mentors if they are at least age 21 and have at least 3 years of post-secondary education. In
    5·1 answer
  • Phil wants to make a dark themed superhero movie. What could be his target demographic
    11·2 answers
  • In dos operating system ,write a command to delete the directory as well as the files of the directory ''world'' on drive E.
    15·1 answer
  • 11.6 Code Practice edhesive
    11·1 answer
  • Why can videos be streamed from the cloud to a computer with no loss in
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!