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
victus00 [196]
3 years ago
10

Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a statement to output the month,

a slash, and the year. End with newline. The program will be tested with inputs 1 2000, and then with inputs 5 1950. Ex: If the input is 1 2000, the output is: 1/2000 Note: The input values come from user input, so be sure to use scnr.nextInt statements, as in birthMonth
Computers and Technology
1 answer:
Alexus [3.1K]3 years ago
4 0

Answer:

The java program fulfilling all the requirements is given below.

import java.util.Scanner;

public class BirthDate {

   

   // variable to hold month

   static int birthMonth;

   

   // variable to hold month

   static int birthYear;

   

   public static void main(String args[]) {

   

   // object of Scanner created to enable user input  

     Scanner scnr = new Scanner(System.in);

     

     // user input taken for month of birth

     System.out.println("Enter the month of birth ");

     birthMonth = scnr.nextInt();

     

     // user input taken for year of birth

     System.out.println("Enter the year of birth ");

     birthYear = scnr.nextInt();

     

     // birth date is displayed in the mentioned format

     System.out.print("The birth date is " + birthMonth + "/" + birthYear);

     

     // ending with newline

     System.out.println("");

   }

}

OUTPUT

Enter the month of birth  

1

Enter the year of birth  

2000

The birth date is 1/2000

Enter the month of birth  

5

Enter the year of birth  

1950

The birth date is 5/1950

Explanation:

The above program is described below.

1 – The variables are declared static since they are used in main() method which is static. Both variables are declared integers as per the question.

2 – Program begins with taking user input for month of the birth followed by year of the birth.

3 – The user input is taken separately for both variables using scanner object, scnr, as per the question requirement.

4 – The birth date is displayed to the console output in the format mentioned in the question: month / year, month of birth followed by slash followed by year of birth. The display statement is written as System.out.print("").

5 – The program is tested using the set of values given in the question.

6 – The input for month and year is not tested for validity since this is not mentioned in the question.

7 – The program ends with newline given by System.out.println("").

8 – print() method displays the output. The println() displays output and inserts a new line after the output.

You might be interested in
What is the output of the following code? Select all that apply c=0 while ( c < 11 ) c = c + 6
Andreyy89

Answer:

crop=6

Explanation:

6 0
1 year ago
What is the meaning of the FN key and what is its Function
nevsk [136]

fn is to talk to the computer

7 0
3 years ago
This part of the electromagnetic spectrum can be used to generate power.
timurjin [86]
A. Gamma Rays is the answer. 
6 0
3 years ago
Read 2 more answers
What is an acceptable alternative to installing an audible backup alarm?
san4es73 [151]
<span>One alternative is the use of an observer/signal person. Due to the piercing noise that is usually associated with audible back-up alarms and its noise intrusiveness to nearby residents, having an observer who signals to others of oncoming construction equipment will meet the same safety requirement as having an audible backup alarm</span>
5 0
3 years ago
Which company has the comparative advantage in producing large tubes of toothpaste?
juin [17]

Answer:

Explanation:

This question is about a comparative advantage, this is the ability to produce a good service at lower opportunity cost, in this case, there is table with 4 companies, where one of them has this comparative advantage, but this depends on what company can produce more large of toothpaste because the costumer can find the product in a lower price.

There are four companies in this example:

Sparkling

Bright White

Fresh!

Mmmint

Choose the company that can produce more products assuming the table.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program, NumberStatistics.java, that reads an unspecified number of integers. The program ends with the input 0. The pro
    14·1 answer
  • Identify the data link trailer blocker
    14·1 answer
  • Using the ____ browsing mode offered by some browsers can prevent personal information from being left on a public computer.
    9·1 answer
  • Omar wants to know how his organization has been doing financially over the last year. He wants to also compare this information
    5·2 answers
  • What is modem please give me answer​
    13·1 answer
  • What is a computer OPERATING SYSTEM?
    5·1 answer
  • Which of the following is NOT an example of soft skill?
    8·1 answer
  • A style sheet consists of CSS ______________________ that specify the layout and format properties to apply to an element. *
    13·1 answer
  • Match the data type to the given data.
    7·1 answer
  • Word can only print documents on one size of paper.<br><br> True or false
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!