Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement an application that reads a sequence of up to 25 pairs of n

ID: 3764875 • Letter: D

Question

Design and implement an application that reads a sequence of up to 25 pairs of names and postal (ZIP) codes for individuals or the user can press enter to quit.Store the data in an object designed to store a first name (string), last name (string), and postal code (int).Assume that each line of input will contain two strings followed by an interger value, each separated by a tab character.Then, after the input has been read in, print the list in an appropriate format to the screen. For displaying the output, must use the foreach construct! Also only display valid input. Do not display blank lines or nulls. This should use only two classes, the main and a pogo.

Sample output:

Enter 25 accounts of less. (Press [Enter] to quit.)

Format: First Name [tab] Last Name [tab] Postal Code

Enter account: Jimmy World 98101

Account Info

World, Jimmy 98101

Explanation / Answer

import java.util.*;

class pogo
{
   String fn,ln;
   int zip;
}

class Single_lin_input
{
   public static void main(String args[])
   {
       Scanner s=new Scanner(System.in);
       int i,c=0;
       pogo o[]=new pogo[25];
       String lin;
       for(i=0;i<25;i++)
       {
           System.out.println("Enter

First Name, Last Name & Zip on Single Line");
           lin=s.nextLine();
           String[] inputAfterSplit =

lin.split(" ");

           o[i].fn = inputAfterSplit[0];
           o[i].ln=inputAfterSplit[1];
           o[i].zip=Integer.parseInt

(inputAfterSplit[2]);
           if(o[i].fn=="" || o

[i].ln==""||o[i].zip==0)
               break;
           c++;
       }

       for(i=0;i<c;i++)
       {
           System.out.println(o[i].fn+"

"+o[i].ln+" "+o[i].zip);
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote