Question

package week_3; import java.util.Scanner; import java.util.*; //import java.lang.*; //import java.io.*; /** Write a program that can...

package week_3;

import java.util.Scanner;
import java.util.*;
//import java.lang.*;
//import java.io.*;

/**

 Write a program that can help decide if a particular programming project
 is best solved using a Waterfall or Agile methodology.

 Your program should ask the user:

 • How many programmers will be on the team   [ More than 30 programmers -> Waterfall ]
 • If there needs to be firm deadlines and a fixed schedule  [ Yes - > Waterfall ]
 • If the programmers have experience in requirements, analysis and testing as well as coding [ Yes - > Agile ]
 • If there are stringent quality control requirements   [ Yes -> Waterfall ]
 • If early integration is desirable   [ Yes -> Agile ]
 • If the customer will be requiring working models early in the process  [ Yes -> Agile ]
 
 There's a `yesNoInput` method in the InputUtils library that returns boolean values from yes/no user input.
 (If the user types 'n' or 'no', the method returns false. If the user types 'y' or 'yes' the method returns true.)
 
 Write a method called agileOrWaterfall,
 which takes this data as integer and boolean arguments.
 **The arguments should be provided in the order given above**.
 `agileOrWaterfall` will return a String, a suggestion on whether Agile, or Waterfall, or either, may be is best.
 
 To decide, check how many factors are in favor of Agile. If there are 4 or more factors in favor of Agile, then return `AGILE`.
 If there are 4 or more factors in favor of Waterfall, return `WATERFALL`.
 If there are an equal number of factors in favor of Agile and Waterfall, returns `EITHER`.
 
 Notice that there are three global constants AGILE, WATERFALL and EITHER.
 Your agileOrWaterfall method should return one of these Strings.
 
 Use your agileOrWaterfall method in your program to suggest which methodology to use.

 Your main method should do the task of asking questions and printing the result.
 Your agileOrWaterfall method should be given the relevant data, and do the processing,
 deciding, and returning the result.

 */
public class Question_3_Agile_Or_Waterfall {

    public final String AGILE = "Agile";
    public final String WATERFALL = "Waterfall";
    public final String EITHER = "Either";

    // don't modify this part
    public static void main(String[] args) {
        new Question_3_Agile_Or_Waterfall().methodology();
    }


    public void methodology() {

        // TODO Ask user the 6 questions
        String ch[] = new String[6];
        Scanner sc = new Scanner(System.in);
        System.out.println("How many program will be on the team:");
        int n = sc.nextInt();
        if (n > 30)
            ch[0] = "Wanterfall";
        else
            ch[0] = "Agile";

        System.out.println("When there is need to be firm deadlines and a fixed schedule:");
        if (sc.next().charAt(0) == 'y')
            ch[1] = "Waterfall";
        else
            ch[1] = "Agile";
        System.out.println("If the programmers have experience in requirements, analysis and testing as well as codig:");
        if (sc.next().charAt(0) == 'y')
            ch[2] = "Agile";
        else
            ch[2] = "Waterfall";

        System.out.println("if there are stringent quality control requirements:");
        if (sc.next().charAt(0) == 'y' || sc.next().charAt(0) == 'Y')
            ch[3] = "Waterfall";
        else
            ch[3] = "Agile";
        System.out.println("If early integration is desirable:");
        if (sc.next().charAt(0) == 'y' || sc.next().charAt(0) == 'Y')
            ch[4] = "Agile";
        else
            ch[4] = "Waterfall";
        System.out.println("If the customers will be requiring working models early in the process:");
        if (sc.next().charAt(0) == 'y' || sc.next().charAt(0) == 'Y')
            ch[5] = "Agile";
        else
            ch[5] = "Waterfall";


        // TODO Call the agileOrWaterfall method
        String suggestion = agileOrWaterfall(ch);
        // TODO Use the suggestion agileOrWaterfall returns to print a message for the user.
        System.out.println("Programing project is best solved using" + suggestion + "methodology");

    }


    // TODO write a public agileOrWaterfall method. It should have this name, and take
    public String agileOrWaterfall(String ch[]) {
        // the 6 arguments needed, in the same order given in the description.
        // TODO this function should a String - one of the three Strings AGILE, WATERFALL or EITHER.
        // For example, if your method determines that Agile is best, write a statement like
        //      return AGILE;  // return the value in the AGILE constant

        int a = 0, w = 0, e = 0;
        for (int i = 0; i < 6; i++) {
            if (ch[i] == AGILE)
                a++;
            if (ch[i] == WATERFALL)
                w++;
            if (ch[i] == EITHER)
                e++;
        }
        System.out.println(Arrays.toString(ch));
        if (a > 3)
            return AGILE;
        if (w > 3)
            return WATERFALL;
        else
            return EITHER;
    }
}


0 0
Add a comment Improve this question Transcribed image text
Answer #1

There was some errors in your methodology() method, especially the part of boolean checks. For checking if user entered y or Y, you were calling sc.next() twice, which asks user to enter two values instead of once. So I have corrected it, using a helper method to check if user entered value contains ‘yes’ or ‘y’ in any case. Now the code is working fine. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

// Question_3_Agile_Or_Waterfall.java

package week_3;

import java.util.Scanner;

import java.util.*;

//import java.lang.*;

//import java.io.*;

/**

* Write a program that can help decide if a particular programming project is

* best solved using a Waterfall or Agile methodology.

*

* Your program should ask the user:

*

* • How many programmers will be on the team [ More than 30 programmers ->

* Waterfall ] • If there needs to be firm deadlines and a fixed schedule [ Yes

* - > Waterfall ] • If the programmers have experience in requirements,

* analysis and testing as well as coding [ Yes - > Agile ] • If there are

* stringent quality control requirements [ Yes -> Waterfall ] • If early

* integration is desirable [ Yes -> Agile ] • If the customer will be requiring

* working models early in the process [ Yes -> Agile ]

*

* There's a `yesNoInput` method in the InputUtils library that returns boolean

* values from yes/no user input. (If the user types 'n' or 'no', the method

* returns false. If the user types 'y' or 'yes' the method returns true.)

*

* Write a method called agileOrWaterfall, which takes this data as integer and

* boolean arguments. The arguments should be provided in the order given

* above**. `agileOrWaterfall` will return a String, a suggestion on whether

* Agile, or Waterfall, or either, may be is best.

*

* To decide, check how many factors are in favor of Agile. If there are 4 or

* more factors in favor of Agile, then return `AGILE`. If there are 4 or more

* factors in favor of Waterfall, return `WATERFALL`. If there are an equal

* number of factors in favor of Agile and Waterfall, returns `EITHER`.

*

* Notice that there are three global constants AGILE, WATERFALL and EITHER.

* Your agileOrWaterfall method should return one of these Strings.

*

* Use your agileOrWaterfall method in your program to suggest which methodology

* to use.

*

* Your main method should do the task of asking questions and printing the

* result. Your agileOrWaterfall method should be given the relevant data, and

* do the processing, deciding, and returning the result.

*/

public class Question_3_Agile_Or_Waterfall {

              public final String AGILE = "Agile";

              public final String WATERFALL = "Waterfall";

              public final String EITHER = "Either";

              // don't modify this part

              public static void main(String[] args) {

                           new Question_3_Agile_Or_Waterfall().methodology();

              }

              public void methodology() {

                           // TODO Ask user the 6 questions

                           Scanner sc = new Scanner(System.in);

                           System.out.println("How many programmers will be on the team:");

                           //reading integer answer

                           int q1 = sc.nextInt();

                           //for all other answers, storing the result in boolean variables

                           System.out

                                                       .println("If there needs to be firm deadlines and a fixed schedule:");

                          

                           boolean q2=isYes(sc.next());

                           System.out

                                                       .println("If the programmers have experience in requirements, analysis and testing as well as codig:");

                           boolean q3=isYes(sc.next());

                           System.out

                                                       .println("if there are stringent quality control requirements:");

                           boolean q4=isYes(sc.next());

                           System.out.println("If early integration is desirable:");

                           boolean q5=isYes(sc.next());

                           System.out

                                                       .println("If the customers will be requiring working models early in the process:");

                           boolean q6=isYes(sc.next());

                           // TODO Call the agileOrWaterfall method

                           String suggestion = agileOrWaterfall(q1,q2,q3,q4,q5,q6);

                           // TODO Use the suggestion agileOrWaterfall returns to print a message

                           // for the user.

                           System.out.println("Programing project is best solved using "

                                                       + suggestion + " methodology");

              }

              // TODO write a public agileOrWaterfall method. It should have this name,

              // and take

              public String agileOrWaterfall(int q1, boolean q2, boolean q3, boolean q4,

                                         boolean q5, boolean q6) {

                           // the 6 arguments needed, in the same order given in the description.

                           // TODO this function should a String - one of the three Strings AGILE,

                           // WATERFALL or EITHER.

                           // For example, if your method determines that Agile is best, write a

                           // statement like

                           // return AGILE; // return the value in the AGILE constant

                           int a = 0, w = 0;

                           if (q1 > 30) {

                                         //waterfall

                                         w++;

                           } else {

                                         //agile

                                         a++;

                           }

                           //all other variables are boolean, true means yes, false means no

                           if (q2) {

                                         w++;

                           } else {

                                         a++;

                           }

                           if (q3) {

                                         a++;

                           } else {

                                         w++;

                           }

                           if (q4) {

                                         w++;

                           } else {

                                         a++;

                           }

                           if (q5) {

                                         a++;

                           } else {

                                         w++;

                           }

                           if (q6) {

                                         a++;

                           } else {

                                         w++;

                           }

                           if (a > 3)

                                         return AGILE;

                           if (w > 3)

                                         return WATERFALL;

                           else

                                         return EITHER;

              }

              /**

              * helper method defined to check if a string contains yes or YES or y or Y

              * or yES or any combination of yes

              *

              * @param txt

              *            text to be checked

              * @return true if txt contains yes or y (not case sensitive), else false

              */

              private boolean isYes(String txt) {

                           if (txt.equalsIgnoreCase("yes") || txt.equalsIgnoreCase("y")) {

                                         return true;

                           }

                           return false;

              }

}

/*OUTPUT*/

How many programmers will be on the team:

25

If there needs to be firm deadlines and a fixed schedule:

yes

If the programmers have experience in requirements, analysis and testing as well as codig:

y

if there are stringent quality control requirements:

yes

If early integration is desirable:

n

If the customers will be requiring working models early in the process:

No

[Agile, Waterfall, Agile, Waterfall, Waterfall, Waterfall]

Programing project is best solved using Waterfall methodology

Add a comment
Know the answer?
Add Answer to:
package week_3; import java.util.Scanner; import java.util.*; //import java.lang.*; //import java.io.*; /** Write a program that can...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • package week_3; /** Write a program that can help decide if a particular programming project is...

    package week_3; /** Write a program that can help decide if a particular programming project is best solved using a Waterfall or Agile methodology. Your program should ask the user: • How many programmers will be on the team [ More than 30 programmers -> Waterfall ] • If there needs to be firm deadlines and a fixed schedule [ Yes - > Waterfall ] • If the programmers have experience in requirements, analysis and testing as well as coding...

  • Make a FLOWCHART for the following JAVA Prime Number Guessing Game. import java.util.Random; import java.util.Scanner; public...

    Make a FLOWCHART for the following JAVA Prime Number Guessing Game. import java.util.Random; import java.util.Scanner; public class Project2 { //Creating an random class object static Random r = new Random(); public static void main(String[] args) {    char compAns,userAns,ans; int cntUser=0,cntComp=0; /* * Creating an Scanner class object which is used to get the inputs * entered by the user */ Scanner sc = new Scanner(System.in);       System.out.println("*************************************"); System.out.println("Prime Number Guessing Game"); System.out.println("Y = Yes , N = No...

  • Complete the code: package hw4; import java.io.File; import java.io.IOException; import java.util.LinkedList; import java.util.Scanner; /* * This...

    Complete the code: package hw4; import java.io.File; import java.io.IOException; import java.util.LinkedList; import java.util.Scanner; /* * This class is used by: * 1. FindSpacing.java * 2. FindSpacingDriver.java * 3. WordGame.java * 4. WordGameDriver.java */ public class WordGameHelperClass { /* * Returns true if an only the string s * is equal to one of the strings in dict. * Assumes dict is in alphabetical order. */ public static boolean inDictionary(String [] dict, String s) { // TODO Implement using binary search...

  • Fix the following null pointer error. import java.util.*; import java.io.*; public class PhoneBook { public static...

    Fix the following null pointer error. import java.util.*; import java.io.*; public class PhoneBook { public static void main(String[]args)throws IOException { PhoneBook obj = new PhoneBook(); PhoneContact[]phBook = new PhoneContact[20]; Scanner in = new Scanner(System.in); obj.acceptPhoneContact(phBook,in); PrintWriter pw = new PrintWriter("out.txt"); obj.displayPhoneContacts(phBook,pw); pw.close(); } public void acceptPhoneContact(PhoneContact[]phBook, Scanner k) { //void function that takes in the parameters //phBook array and the scanner so the user can input the information //declaring these variables String fname = ""; String lname = ""; String...

  • Modify the below Java program to use exceptions if the password is wrong (WrongCredentials excpetion). import java.util....

    Modify the below Java program to use exceptions if the password is wrong (WrongCredentials excpetion). import java.util.HashMap; import java.util.Map; import java.util.Scanner; class Role { String user, password, role; public Role(String user, String password, String role) { super(); this.user = user; this.password = password; this.role = role; } /** * @return the user */ public String getUser() { return user; } /** * @param user the user to set */ public void setUser(String user) { this.user = user; } /** *...

  • Professionally and thoroughly comment on this code. //BinarySearchTree.java package Project.bst; //imports required import java.io.BufferedReader; import java.io.FileNotFoundException;...

    Professionally and thoroughly comment on this code. //BinarySearchTree.java package Project.bst; //imports required import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; class BSTTreeNode{    BSTTreeNode left, right;    String data; public BSTTreeNode(){    left = null;    right = null;    data = null; } public BSTTreeNode(String n){    left = null;    right = null;    data = n; } public void setLeft(BSTTreeNode n){    left = n; } public void setRight(BSTTreeNode n){   ...

  • complete this in java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class...

    complete this in java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class WordDetective { /** * Picks the first unguessed word to show. * Updates the guessed array indicating the selected word is shown. * * @param wordSet The set of words. * @param guessed Whether a word has been guessed. * @return The word to show or null if all have been guessed. */    public static String pickWordToShow(ArrayList<String> wordSet, boolean []guessed) { return null;...

  • /* * CPS150_Lab10.java */ import java.io.*; import java.util.*; /** * CPS 150, Fall 2018 semester *...

    /* * CPS150_Lab10.java */ import java.io.*; import java.util.*; /** * CPS 150, Fall 2018 semester * * Section N1 * * Lab Project 13: Comparing Java Strings * * @author *** Replace with your name *** */ public class CPS150_Lab13 { static final Scanner KBD = new Scanner(System.in); static final PrintStream OUT = System.out; // TO DO: Implement each of the following 4 methods, // using the String compareTo method: /* * lessThan(String, String) -> boolean * * method is...

  • Write one JUnit test in Java for the following: Essay class: import java.util.Scanner; public class Essay implements IAn...

    Write one JUnit test in Java for the following: Essay class: import java.util.Scanner; public class Essay implements IAnswer{ private String question; public Essay(String q){ this.question = q; } //This function returns question text public String getQuestionText() {    return question; } //This function takes answer from user public void answer(String userAnswer) {    // Take care of answer } @Override public String getAnswer() { System.out.println(question); Scanner scan = new Scanner(System.in); System.out.print("Answer: "); String ans =scan.nextLine(); scan.close(); if(ans.length() <=140){ return ans; }else{ return...

  • import java.util.Arrays; import java.util.Random; import java.util.Scanner; /** * TODO Write a summary of the role of...

    import java.util.Arrays; import java.util.Random; import java.util.Scanner; /** * TODO Write a summary of the role of this class in the * MasterMind program. * * @author TODO add your name here */ public class MasterMind { /** * Prompts the user for a value by displaying prompt. * Note: This method should not add a new line to the output of prompt. * * After prompting the user, the method will consume an entire * line of input while reading...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT