SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 21 Dec 2017 My Price 8.00

public static void main(String[] args)// intitize

Please see questions in bold text in the coding below. I am confused on some of this. Any help is appreciated. Thank you.

 

package membership2;

 

import java.util.Arrays;

 

import javax.swing.JOptionPane;

 

public class Membership2 {

 

   public static void main(String[] args) {

      // intitize

      String ans;         // Catch the users answers

      int cont;           // Continue

      int fNum;           // Number of family members

      String family[];    // Array that will contain all family

                                    // members.

      

      do {

         // Ask how many members of the family

         ans = JOptionPane.showInputDialog(null,

               "How many members in the family?n" +

               "You will be prompted for each members first name.");

         

                       // Convert the string answer to a number

         fNum = Integer.parseInt(ans);

         

                       // Store the family names into an array

         family = storeFamily(fNum);

         

                       // Print the family list

         printFamily(family);

         

                       // Sort the family

         family = sortFamily(family);

         

                       // Print the sorted family list

         printFamily(family);

         

                       // Ask if user wants to enter another family

         cont = JOptionPane.showConfirmDialog(null,

               "Do You want to add another family?",

               "Membership", JOptionPane.YES_NO_OPTION);

         

      }while(cont == JOptionPane.YES_NO_OPTION);

      

      JOptionPane.showMessageDialog(null, "Please come again");

 

   }    // End of main method

 

       // Is this an accurate description for the coding below: Adds a method that sorts the array and returns the results

   private static String[] sortFamily(String[] family) {

      Arrays.sort(family);

      return family;

   }

 

       // Is this an accurate description for the coding below: Adds method that displays result of sorted array

   private static void printFamily(String[] family) {

      String str = "Members of the family : n";

      for(String s : family) {

         str = str + s + "n";

      }

// Why do I get an error message on the line below?

      JOptionPane.showMessageDialog(null, str "Message", JOptionPane.INFORMATION_MESSAGE);

   }

 

       // Is this a correct description of the method below: Adds method that counts and stores new family member input

   private static String[] storeFamily(int count) {

      

      String[] family = new String[count];

      

      String lastname = JOptionPane.showInputDialog(null,

            "What is the name of the family ?");

               

      // The line below initializes an array and executes as many times as there are family members?

      for(int i=0 ;i< count ;i++) {

         

         String firstname = JOptionPane.showInputDialog(null,

               "Please enter the each first name of family member one at a time. ");

       

         family[i] = firstname + " " + lastname;

         

      }

      

      return family;

   }

 

}

Answers

(5)
Status NEW Posted 21 Dec 2017 07:12 AM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)