In: Computer Science
Write program#1 upload .java file.
#1 Write a java program that prompts the user for input using the Scanner class.
<END>
CODE IN JAVA:
Address.java file:
import java.util.Scanner;
class Address {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("Enter the first name:");
String firstName = sc.nextLine();
System.out.print("Enter the last name:");
String lastName = sc.nextLine();
System.out.print("Enter the city:");
String city = sc.nextLine();
System.out.print("Enter the state:");
String state = sc.nextLine();
System.out.print("Enter the zipcode:");
String zipCode = sc.nextLine();
zipCode = zipCode.replace('0', 'N');
zipCode = zipCode.replace('7', 'J');
firstName = firstName.toUpperCase();
lastName = lastName.toUpperCase();
String fullName = firstName +" "+lastName;
city = city.toUpperCase();
state = state.toUpperCase();
zipCode = zipCode.toUpperCase();
System.out.println("Full name:"+fullName);
System.out.println("Mailing address: "+city+", "+state+", "+zipCode);
}
}
OUTPUT: