complete the method named countdown (method  stub provided) so that it accepts an int countFrom as its parameter and  prints each number from countFrom to

complete the method named countdown (method  stub provided) so that it accepts an int countFrom as its parameter and  prints each number from countFrom to 1 on a single line separated by a  space. This method should not return anything (void return type).

Hint:  Use a loop and think about the starting value you want to print, the  ending value that will print, and how you want to update the value  between iterations.

Example: countdown(5) should print: 5 4 3 2 1  Example2: countdown(-1) should not print anything. Example3: countdown(9) should print: 9 8 7 6 5 4 3 2 1  

Ensure you are thoroughly calling and testing your methods before submitting to zyBooks.

Problem 2 – Arrays as Parameters

Complete  the curve method (method stub provided for you) so that it loops  through the int[] grades, incrementing each non-zero grade by 2. Grades  of 0 should not be changed. This method should not print or return  anything, but should modify the contents of the grades array.

Hint – you can test that your method works in main by printing the values in grades both before and after this method is called.

Example: Passing in an int[] containing: {95, 80} should modify the array to {97,82} Example2: Passing in a int[] containing: {70, 0, 99} should modify the array to {72, 0, 101}  

Problem 3 – Returning Arrays, Arrays as Parameters, String methods

Write  a method named acronyms that accepts an array of type String as its  parameter and returns an array of type char. This method stub is not  provided for you. Method name, return type, and parameter(s) should  match exactly to receive credit. You should not use the keyword static  in the method header.

Your method should  create a new char array the same size as the String array passed in.  You should then use a loop to populate the char array with the first  letter of each individual String stored in the array.

Hint – the charAt method in the String class retrieves a single char from a specified index.

Example:  Passing in an String[] containing: {“tiger”, “king”} should return a  char[] of size 2 containing {‘t’, ‘k’} Example2: Passing in an String[] containing: {“go dawgs”, “uga”, “java”}  should return a char[] of size 3 containing {‘g’, ‘u’, ‘j’} 

Problem 4 – Scanner in methods, String methods, Algorithm design, Return Statements

Write  a method named setPassword that accepts a Scanner object as its  parameter and returns a boolean. This method stub is not provided for  you. Method name, return type, and parameter(s) should match exactly to  receive credit. You should not use the keyword static in the method  header.

Your method should read in a  String password using the nextLine method and the the Scanner object  passed in as the method parameter. Your method should then return either  true or false depending on if all criteria of a password is met.

A valid password (returning true) would have the following criteria:

  • The password contains at least 8 characters
  • The password contains at least 1 capital letter/char
  • The password contains at least 1 lowercase letter/char

If  ALL of the above conditions are met, your method should return true. If  any of the above conditions are NOT met, your method should return  false.

Example: a user input of “Coding99” or “Java12345” would return true Example2: a user input of “Java123” would return false //only 7 characters Example3: a user input of “JAVA12345” would return false //no lowercase Example4: a user input of “java12345” would return false //no uppercase

import java.util.Scanner; //imported for you!

public class Exam2{//Problem 1   public void countdown(int countFrom)   {       //YOUR CODE HERE   } 

   //Problem 2   public void curve(int[] grades)   {       //YOUR CODE HERE   } 

//Problem 3   //method stub not provided – YOUR CODE HERE 

   //Problem 4   //method stub not provided – YOUR CODE HERE

}

import java.util.*; //All items in java.util package (Scanner, ArrayList, HashSet, etc.) imported for youpublic class Main{  public static void main(String[] args)  {        //You can test your code here.         //This file is not graded.  } 

}

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

This week, you will submit the second project, the Desktop Migration Proposal. Using the requirements analysis your manager provided and the Internet

This week, you will submit the second project, the Desktop Migration Proposal. Using the requirements analysis your manager provided and the Internet research you conducted, submit your recommendation to the assignment folder. As you are writing your recommendation, ensure your analysis and recommendations align with your manager’s priorities and concerns.

Comparing and contrasting space and time complexity in algorithm analysisWhen performing an algorithm analysis, **time complexity** and **space

Comparing and contrasting space and time complexity in algorithm analysisWhen performing an algorithm analysis, **time complexity** and **space complexity** are two of the most significant variables to consider. Although they both gauge an algorithm’s efficiency, they focus on distinct areas of performance.**Time complexity** is the relationship between an algorithm’s execution

Career Focus (Required/Graded) SubscribeThe CompTIA A+ certification demonstrates to employers that you have the knowledge, ability, and skills in

Career Focus (Required/Graded) SubscribeThe CompTIA A+ certification demonstrates to employers that you have the knowledge, ability, and skills in entry-level PC technology. Many industry insiders started with the CompTIA A+, and that led them to higher-paying, more complex jobs in both IT and cybersecurity. Many large corporations such as Apple, Cisco,

CompTIA’s T/S Methodology (Required/Graded) SubscribeFor this discussion, you will be assessing the following help desk ticket below from Chikako

CompTIA’s T/S Methodology (Required/Graded) SubscribeFor this discussion, you will be assessing the following help desk ticket below from Chikako (connectivity issue). Use the CompTIA 6-step troubleshooting process below to help figure out the connectivity issue. CompTIA 6-Step Troubleshooting Process: Identify the problem. Establish a theory of probable cause. Evaluate the theory

Accounting: Business and finance: computerscience: Economics: Marketing: Social Science Am a professional academic writer, content creator and, copywriter

Accounting: Business and finance: computerscience: Economics: Marketing: Social Science Am a professional academic writer, content creator and, copywriter with 7 years of research based experience.  My accounting: Business and finance: computerscience: Economics: Marketing: Social Science Am a professional academic writer, content creator and, copywriter with 7 years of research based

Explain why we cannot corrupt the output buffer of Buffovrflw_Demo4 through we can trigger a segmentation fault We cannot corrupt the output buffer of

Explain why we cannot corrupt the output buffer of Buffovrflw_Demo4 through we can trigger a segmentation fault We cannot corrupt the output buffer of `Buffovrflw_Demo4` because the program is likely designed with protections such as stack canaries, non-executable stack, or address space layout randomization (ASLR). These mechanisms prevent direct buffer