1 write a complete java method called sumnums that takes no


Part 1 - Methods - You will simply just write methods as the questions ask you to.

  1. 1. Write a complete Java method called sumNums that takes no parameters and returns an integer. The method uses a do-while loop to ask the user to enter a series of positive integer values and keeps a running total. Use a sentinel (-1) to allow the user to indicate when they are finished. The method returns the total.

2. Write a complete Java method called checkPassword that takes a String as a parameter (password) and returns a boolean. First, check that the password is at least 8 characters long. Then use a while loop to check that the password contains at least one digit. If the password has the correct length and contains a digit, return true, otherwise return false

3. Write a complete Java method called authenticate that takes two Strings (username, password) as parameters and returns a boolean. If the username parameter has the value "Chucky" and the password parameter has the value "Cheese1", return true. Otherwise return false.

4. Write a complete Java method called getScoreSheet that takes two ints as parameters (rows and columns) and constructs a 2-dimensional array of doubles (calles scores) with a size based on the rows and columns parameters. Use a nested loop to initialize each value in the array to 100.00. The method returns the scores array.

5. Write a complete Java method called writeList that takes an ArrayList of Strings as a parameter and writes each String as a line in a text file. Make sure to handle the Exception that might be thrown and print the error message to the command line.

Part 2 - Complete JAVA Program - You will write a complete JAVA program as requested below.

Write a complete Java program to compute the cost of your annual coffee consumption. (If you don't drink coffee, you can substitute tea, soda, or something else.)

The main method calls three methods to do this:

getDailyCost: requests from the user the estimated amount they spend on coffee on each day of the week, Sunday through Saturday. These values are stored in array of 7 doubles called dailyCost. The method returns this array.

getAnnualCost: takes an array of doubles as a parameter (the dailyCost array) and computes the annual cost for coffee (or tea, soda, etc). Assume 52 weeks in a year. The method returns the annual cost as a double.

printAnnualCost: takes a double (the annual cost) as a parameter and prints it to the command line as, for example: "Your estimated total meal plan cost is: $1375.00."

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: 1 write a complete java method called sumnums that takes no
Reference No:- TGS01192659

Now Priced at $35 (50% Discount)

Recommended (97%)

Rated (4.9/5)

A

Anonymous user

5/5/2016 12:47:55 AM

By applying the concepts and theories of Java, respond to the following questions by showing all the codes and snapshots of the outcomes. 1) Write down a complete Java method called sumNums which takes no parameters and returns an integer. The method employs a do-while loop to ask the user to enter a series of the positive integer values and keeps a running total. Make use of sentinel (-1) to let the user to point out whenever they finished. The method returns the total. 2) Write down a complete Java method called checkPassword which takes a String as the parameter (password) and returns Boolean. Primary, check the password is at a minimum of 8 characters long. Then make use of a while loop to check that the password includes at least one digit. If the password consists of the correct length and includes a digit, return true, or else return false.