Answer:
- int birthMonth, birthYear;
-
- cin >> birthMonth;
- cin >> birthYear;
-
- cout << birthMonth << "/" << birthYear;
Explanation:
Firstly, we declare two integer type variables, <em>birthMonth</em> and <em>birthYear </em>(Line 1). Next, we use cin as the standard input stream to get the birth month and year from user (Line 3 - 4). Finally, we print the date using cout. We can chain the << operator to create a date string with format birthMonth/birthYear as expected by question (Line 6)
Answer:
// program in java.
import java.util.*;
// class definition
class Main
{// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// object to read input
Scanner scr=new Scanner(System.in);
// ask to enter name
System.out.print("Enter Your name: ");
// read name from user
String NAME=scr.nextLine();
// print message
System.out.println("Greetings,"+NAME);
}catch(Exception ex){
return;}
}
}
Explanation:
Read name from user with the help of scanner object and assign it to variable "NAME".Then print a Greetings message as "Greetings,NAME" where NAME will be replaced with user's input name.
Output:
Enter Your name: Rachel
Greetings,Rachel
Enter tab would complete an entry. I hope that helped ya!