Question

In: Computer Science

Write program#1 upload .java file. #1 Write a java program that prompts the user for input...

Write program#1 upload .java file.

#1 Write a java program that prompts the user for input using the Scanner class.

  • First to enter their first name.
  • Then prompts the user to enter their last name.
  • Then prompts the user to enter their city.
  • Then prompts the user to enter their state.
  • Then prompts the user to enter their zip code.  
  • Concatenate first name and last name into full_name. Using String Class is optional.
  • Use the String Class to replace zip code "0" with "N", replace "7" with "J".
  • Use the String Class to make all the values upper case.
  • Use the String Class to determine the length of full_name.  
  • Print on first line full_name and length of full_name.
  • Print all on second line mailing address, including zip_string.

<END>

Solutions

Expert Solution

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:


Related Solutions

Write program#1 upload .java file. #1 Write a java program that prompts the user for input...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input using the Scanner class. First to enter their first name. Then prompts the user to enter their last name. Then prompts the user to enter their city. Then prompts the user to enter their state. Then prompts the user to enter their zip code. Concatenate first name and last name into full_name. Using String Class is optional. Use the String Class to replace zip...
Question 1: Write a Java program that prompts the user to input a file name (existing...
Question 1: Write a Java program that prompts the user to input a file name (existing text file), then calculate and display the numbers of lines in that file. Also calculate and display the length of the longest line in that file. For example, if the input file has the following lines: Hello This is the longest line Bye The output should be: The file has 3 lines. The longest line is line 2 and it has 24 characters. Test...
JAVA: Write a program that prompts the user to input a type of medication and the...
JAVA: Write a program that prompts the user to input a type of medication and the output will be a list of side effects that can occur from that medication.
Write a Java program that prompts the user to input a word (String). The program must...
Write a Java program that prompts the user to input a word (String). The program must print the reversed word with all consecutive duplicate characters removed. The program must contain the following classes: - The StackX class (you can use the Java Stack class). - The Reverse class which must contain a private data field called “word” of type string, a constructor, and a void method called revNoDup(). The revNoDup() method must reverse the word and remove the consecutive duplicate...
Write a Java program that prompts the user to input a string and prints whether it...
Write a Java program that prompts the user to input a string and prints whether it is a palindrome. A palindrome is a string which reads the same backward as forward, such as Madam (disregarding punctuation and the distinction between uppercase and lowercase letters). The program must use the stack data structure. The program must include the following classes: The StackX class (or you can use the Java Stack class). The Palindrome class which must contain a method named palindrome()...
1. Write a program that prompts the user for a filename, then reads that file in...
1. Write a program that prompts the user for a filename, then reads that file in and displays the contents backwards, line by line, and character-by character on each line. You can do this with scalars, but an array is much easier to work with. If the original file is: abcdef ghijkl the output will be: lkjihg fedcba Need Help with this be done in only PERL. Please use "reverse"
(JAVA) Create a program that prompts the user for an age input. The program defines the...
(JAVA) Create a program that prompts the user for an age input. The program defines the age group of the user. Follow the table below to construct the output for your program. Age Age Group 0 Baby 1-3 Toddler 4-11 Child 12-17 Teenager 18-21 Young Adult 22-64 Adult 65+ Senior Negative Number Invalid Input Sample Input Enter an age: 18 Sample Output: You are a young adult. Sample Input Enter an age: 29 Sample Output: You are an adult. Sample...
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
Write a program that prompts the user to input a string. The program then uses the...
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning of your program and...
Write a program that prompts the user to enter a file name, then opens the file...
Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT