Question

Problem 14: all 5 parts must be complete to receive credit for the question    /**...

Problem 14: all 5 parts must be complete to receive credit for the question
  
/**
* q1: Write a public static method named q1 that takes no parameters and returns void. The
* method should print all the integers from -8 to 47 to the screen. The output should be
* inclusive of these end points
*/
  
  
  
  
/**
* q2: Write a public static method named q2 that takes two ints as parameters and returns a
* boolean. The output should be the evaluation of the boolean expression: The first
* parameter is less than or equal to 25 or the second parameter is less than 2
*/
  
  
  
  
/**
* q3: Write a public static method named q3 that takes a String as a parameter and returns a
* String. The returned String is based on the input String as follows:
*
* If the input String has no characters, return "empty"
* If the input String has less than 3 characters, return "short"
* If the input String has 3 or more characters but less than 12, return "medium"
* If the input String has greater than or equal to 12 characters, return "long"
* If the input String contains any instances of the letter 'y', return "found y" regardless
* of the length of the input
*/
  
  
  
  
/**
* q4: Write a public static method named q4 that takes two ints as parameters and returns a
* boolean. The output should be the evaluation of the boolean expression: The first
* parameter is less than or equal to -9 and the second parameter is less than or equal to 2
*/
  
  
  
  
/**
* q5: Write a public static method named q5 that takes no parameters and returns void. The
* method should print all the integers from 1 to 69 to the screen. The output should be
* inclusive of these end points
*/
  
  
  
  
public static void main(String[] args){
  
/* Test your code here to verify it is correct before submitting */
  
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class Qs {
    /**
     * q1: Write a public static method named q1 that takes no parameters and returns void. The
     * method should print all the integers from -8 to 47 to the screen. The output should be
     * inclusive of these end points
     */
    public static void q1() {
        for (int i = -8; i <= 47; i++) {
            System.out.println(i);
        }
    }


    /**
     * q2: Write a public static method named q2 that takes two ints as parameters and returns a
     * boolean. The output should be the evaluation of the boolean expression: The first
     * parameter is less than or equal to 25 or the second parameter is less than 2
     */

    public static boolean q2(int n1, int n2) {
        return n1 <= 25 || n2 < 2;
    }


    /**
     * q3: Write a public static method named q3 that takes a String as a parameter and returns a
     * String. The returned String is based on the input String as follows:
     * <p>
     * If the input String has no characters, return "empty"
     * If the input String has less than 3 characters, return "short"
     * If the input String has 3 or more characters but less than 12, return "medium"
     * If the input String has greater than or equal to 12 characters, return "long"
     * If the input String contains any instances of the letter 'y', return "found y" regardless
     * of the length of the input
     */
    public static String q3(String str) {
        if (str.length() == 0) {
            return "empty";
        } else if (str.length() < 3) {
            return "short";
        } else if (str.length() < 12) {
            return "medium";
        } else {
            return "long";
        }
    }


    /**
     * q4: Write a public static method named q4 that takes two ints as parameters and returns a
     * boolean. The output should be the evaluation of the boolean expression: The first
     * parameter is less than or equal to -9 and the second parameter is less than or equal to 2
     */
    public static boolean q4(int n1, int n2) {
        return n1 <= -9 || n2 <= 2;
    }


    /**
     * q5: Write a public static method named q5 that takes no parameters and returns void. The
     * method should print all the integers from 1 to 69 to the screen. The output should be
     * inclusive of these end points
     */
    public static void q5() {
        for (int i = 1; i <= 69; i++) {
            System.out.println(i);
        }
    }


    public static void main(String[] args) {
        
        q1();
        System.out.println(q2(1, 5));
        System.out.println(q2(1, 5));
        System.out.println(q4(2, 5));
        q5();

    }
}
Add a comment
Know the answer?
Add Answer to:
Problem 14: all 5 parts must be complete to receive credit for the question    /**...
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
  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • Write a public static method named getMaxOf2Ints that takes in 2 int arguments and returns the...

    Write a public static method named getMaxOf2Ints that takes in 2 int arguments and returns the Maximum of the 2 values Write a public static method named getMinOf2Ints that takes in 2 int arguments and returns the Minimum of the 2 values Write apublic static method named getMaxOf3Ints that takes in 3 int arguments and returns the Maximum of the 3 values Write a public static method named getMedianOf3Ints that takes in 3 int arguments and returns the Median Value...

  • Game Development: Uno For this assignment you will be creating the game of Uno (See the...

    Game Development: Uno For this assignment you will be creating the game of Uno (See the accompanying pdf for the instructions of the game). Your version will adhere to all the rules except that only the next player can issue a challenge against the previous player in regards to penalties, and your games must have at least three (3) players and at most nine (9) players. To begin, you must create the class Card which contains: Private string field named...

  • Make a public class called ManyExamples and in the class... Write a function named isEven which...

    Make a public class called ManyExamples and in the class... Write a function named isEven which takes in a single int parameter and returns a boolean. This function should return true if the given int parameter is an even number and false if the parameter is odd. Write a function named close10 which takes two int parameters and returns an int. This function should return whichever parameter value is nearest to the value 10. It should return 0 in the...

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a...

    JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...

  • JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named...

    JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named problem1. 2. Create a Java class named StringParser with the following: ApublicstaticmethodnamedfindIntegerthattakesaStringandtwocharvariables as parameters (in that order) and does not return anything. The method should find and print the integer value that is located in between the two characters. You can assume that the second char parameter will always follow the firstchar parameter. However, you cannot assume that the parameters will be different from...

  • This is the code I wrote for myprogramminglab It works for 8 out of 9 inputs they use and I...

    Write a full class definition for a class named GasTank , and containing the following members:A data member named amount of type double.A constructor that no parameters. The constructor initializes the data member amount to 0.A function named addGas that accepts a parameter of type double . The value of the amount instance variable is increased by the value of the parameter.A function named useGas that accepts a parameter of type double . The value of the amount data member...

  • Write a static method called printWithSpaces that takes a String as its parameter and prints the...

    Write a static method called printWithSpaces that takes a String as its parameter and prints the characters of the string separated by spaces. For example: > Methods.printWithSpaces("method") m e t h o d You should have a single space after the last character. This method should not return a value. That is similar to this code for printing the string vertically public static void printVertical(String s) { for (int i = 0; i < s.length(); i++) { char c =...

  • Consider the Automobile class: public class Automobile {    private String model;    private int rating;...

    Consider the Automobile class: public class Automobile {    private String model;    private int rating; // a number 1, 2, 3, 4, 5    private boolean isTruck;    public Automobile(String model, boolean isTruck) {       this.model = model;       this.rating = 0; // unrated       this.isTruck = isTruck;    }        public Automobile(String model, int rating, boolean isTruck) {       this.model = model;       this.rating = rating;       this.isTruck = isTruck;    }                public String getModel()...

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