Question

In: Computer Science

Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file...

  1. Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file as LASTNAME_FIRSTNAME_M07HW2. (worth 15 points)

Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form: [email protected].

please help!!!!

Solutions

Expert Solution

Hi,

Hope you are doing fine. I have writrten the code for the above question in java. The logic is pretty straight forward and the clear explanation is provided using the comment sthat have been highlighted in bold. Also have a look at the code snippet below the program to get a clear picture of the indentation of the code.

Program:

import java.util.Scanner;

public class Name {

   public static void main(String[] args) {
       // TODO Auto-generated method stub
       //array to store first names
       String [] first =new String[100];
       //array to store last names
       String [] last =new String[100];
       //sentinel variable of type String which is assigned to 'y' initially
       String sentinel="y";
       //to traverse through the index of array
       int i=0;
       //creating new scanner for input from user
       Scanner sc=new Scanner(System.in);
       System.out.println("Enter first and last names of users\n");
      //while sentinel is not equal to 'n' the loop continues
       while(!sentinel.equals("n"))
       {
           System.out.println("Enter first name: ");
           //Storing the first name entered by user in first[i]
           first[i]=sc.next();
           System.out.println("Enter last name: ");
           //Storing the last name entered by user in last[i]
           last[i]=sc.next();
           System.out.println("Enter any key to continue and 'n' to stop");
           //Taking sentinel input
           sentinel=sc.next();
           //incrementing i value to next index
           i++;
       }
       //Printing empty line
       System.out.println();
       System.out.println("List of emails: ");
       //this for loop traverses the two arrays first and last. Maximum size of both arrays is i
       for(int j=0;j<i;j++)
           //Printing output as per question. '+' is used to concatenate two strings
           System.out.println(first[j]+"."+last[j]+"@mycollege.edu");      
   }

}

Executable code snippet:

Output:


Related Solutions

DIRECTIONS: Complete the following Programming Exercise in Python. Name the file Lastname_Firstname_E1. You just started your...
DIRECTIONS: Complete the following Programming Exercise in Python. Name the file Lastname_Firstname_E1. You just started your summer internship with ImmunityPlus based in La Crosse, Wisconsin. You are working with the forecasting team to estimate how many doses of an immunization drug will be needed. For each drug estimation, you will be provided the following information: corona.txt 39 20 31 10 42 49 54 21 70 40 47 60 - The size of the target population. - The life expectancy, in...
Systems Programming - File Operations Create your version of the tail command in Linux using C...
Systems Programming - File Operations Create your version of the tail command in Linux using C The lseek system call allows you to move the current position anywhere in a file. The call lseek(fd, 0, SEEK_END) moves the current position to the end of the file. The tail command displays the last ten liens of a file. Try it. tail has to move, not to the end of the file, but to a spot ten lines before the end of...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your solutions for each problem solved in a Word or Google document which includes (a) the pseudocode, (b) the C# codes and (c) the execution result (screen capture just the answer part using Snipping Tool, avoiding non-related or blank spaces). Notice for readability, that the (a) & (b) are in text mode and the (c) is in image mode. Use proper titles and wording in...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your solutions for each problem solved in a Word or Google document which includes (a) the pseudocode, (b) the C# codes and (c) the execution result (screen capture just the answer part using Snipping Tool, avoiding non-related or blank spaces). Notice for readability, that the (a) & (b) are in text mode and the (c) is in image mode. Use proper titles and wording in...
C Programming: Write a program that accepts 2 arguments, an input file and an output file....
C Programming: Write a program that accepts 2 arguments, an input file and an output file. The program is to store in the output file the contents of the input file in reverse. If the input file looks like this: Hello World.\n This is Line 2\n This is the end.\n then the output file should look like this: \n .dne eht si sihT\n 2 eniL si sihT\n .dlroW olleH The main program should look like this: int main(int argc, char...
Book - Introduction to Programming Using Visual Basic 11th Edition by David I. Schneider Programming Language...
Book - Introduction to Programming Using Visual Basic 11th Edition by David I. Schneider Programming Language - Visual Studio 2017 RESTAURANT MENU Write a program to place an order from the restaurant menu in Table 4.13. Use the form in Fig. 4.70, and write the program so that each group box is invisible and becomes visible only when its corresponding check box is checked. After the button is clicked, the cost of the meal should be calculated. (NOTE: The Checked...
Systems Programming - File Operations in Linux using C Preventing copying the same file What does...
Systems Programming - File Operations in Linux using C Preventing copying the same file What does the standard cp do if you try to copy a file onto itself? $ cp file1 file1 cp: 'file1' and 'file1' are the same file Modify cp1.c to handle the situation and include comments. /** * @file cp1.c * @brief Uses read and write with tunable buffer size * usage: cp1 src dest */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #define BUFFERSIZE...
2. Describe how you save a file with a new filename in Excel.
2. Describe how you save a file with a new filename in Excel.
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of mv command The mv command is more than just a wrapper around the rename system call. Write a version of mv that accepts two argument. The first argument must be the name of a file, and the second argument may be the name of a file or the name of a directory. If the destination is the name of a directory, then mv moves...
complete a 2 page paper answering this question: What changes will you implement in your personal...
complete a 2 page paper answering this question: What changes will you implement in your personal life in order to be a more accepting and understanding individual?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT