Write two statements to read values for birthMonth and birth
Write two statements to read values for birthMonth and birthYear, separated by a space, then write a statement to output the month, a slash, and the year. End with newline. Ex: The output is shown for user input of: 1 2000 1/2000
Challenge 1.7.2: Read multiple user inputs Activity Write two statements to read values for birthMonth and birthYear, separated by a space, then write a statement to output the month, a slash, and the year. End with newline. Ex: The output is shown for user input of: 1 2000 1/2000 1 import java util. Scanner; 3 public class InputExample 4 public static void mainCString args) 1 Scanner scnr new Scanner System in int birthMonth 0; int birthYear 0; Your solution goes here 10 return 12 h 13 Run Feedback?Solution
Kindly put below lines of code in your provided solution -
//Scans next token of Input as an int value(i.e. birthMonth and birthYear )
birthMonth=scnr.nextInt();
birthYear=scnr.nextInt();
//Print birthMonth and birthYear separation by /
System.out.print(birthMonth _\"/\" +birthYear);
return;
The Complete Code for this is as Follows-
import java.util.Scanner;
Public class InputExample
{
public static void main(String[] args)
{
Scanner scnr=new Scanner(system.in);
int birthMonth = 0;
int birthYear = 0;
birthMonth=scnr.nextInt();
birthYear=scnr.nextInt();
System.out.print(birthMonth + \"/\" +birthYear);
return;
}
}
