Solution:
import java.util.*;
class lab2_1{
public static void main(String []args)
{
String email;
String postalAddress;
System.out.println("Please enter your email address and your postal address");
System.out.println("Enter your email:");
Scanner in=new Scanner(System.in);
email=in.nextLine();
System.out.println("Enter your postal address");
postalAddress=in.nextLine();
String output="The email address entered is: "+email+" and the postal address: "+postalAddress;
System.out.println(output);
}
}
Our first step to complete this program will be declaring
two variables to hold our email and postal address value (email and
postalAddress). Since both variables are
of type String that’s the variable type we are going to use and we are going to
name then accordingly to the values asked in the instruction (email and
postalAddress). Then we are going to let the user know we need its email and
postal address and we use the Scanner method so the user could type the info
needed. After the info is entered, we concatenate both variable value and we
print it out.
No comments:
Post a Comment