Write a complete java method called sumnums

Assignment Help Basic Computer Science
Reference no: EM13899507

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."

Reference no: EM13899507

Questions Cloud

Principle parts of a quality function deployment matrix : Describe the principle parts of a quality function deployment matrix. How is each of the principle parts of a QFD created? What does each part hope to provide the users
Calculate the amount of dividends dragoon paid : Calculate the amount of dividends Dragoon paid using the information given. Prepare a statement of cash flows using the indirect method.
Complete a swott analysis of mergers and acquisitions : Complete a SWOTT analysis of Mergers and acquisitions
Describe the three phases of the life history curve : Describe the three phases of the life history curve. Reliability programs have been used to prolong the lives of tornado sirens that signal the approach of bad weather. Describe a tornado siren in terms of the definition of reliability
Write a complete java method called sumnums : 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 u..
Calculate the amount of dividends firm a and firm b paid : Calculate the amount of dividends Firm A and Firm B paid using the information given. Prepare a statement of cash flows for each firm using the indirect method.
What is the probability that a blue chip will be drawn : The probability of drawing a pink chip from a bowl of different colored chips is 0.35, the probability of drawing a blue chip is 0.46, the probability of drawing a green chip is 0.15, and the probability of drawing a purple chip is 0.04. What is ..
Create sheet sales and put reasonable numbers : Create a file: Pizza_by_First_Last.xlsm . Create sheet Sales and put reasonable numbers for prices (your choice), add create formulas. Put the % for sales tax in H1 (it is 8% in NY).  After that, you need to put formulas in place, add a row for total..
Analyze common ethernet standards found in a switched lan : Analyze common Ethernet standards found in a switched LAN fabric. ? Summarize the nature of Ethernet frames that are processed in LAN switching.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Jewelers is a small jewelry company in a college town

Especially for You Jewelers is a small jewelry company in a college town. Over the last couple of years, it has experienced a tremendous increase in its business. However, its financial performance has not kept pace with its growth. The current syste..

  Describe the importance of hardware independence

Describe the importance of hardware independence. List three benefits of data redundancy. What is the role of Active Directory in the Windows operating system

  Define the matrices

Define the matrices A = [12 16 4;23 1 21;9 10 1], B = [2 7 14;3 11 2;-9 10 12], C = [43 12;13 12], and D = [1 2 3;4 5 6]. Perform the following additions: (1) A+B, (2) A+C, (3) A+D, (4) B+C, (5) B+D, and (6) C+D. Are each of the above additions possi..

  Dscribe implications of e-publishing they effect way we read

Dscribe implications of e-publishing as they effect way we read and understand content. Describe e-books, print on demand, copyright and XrML and use of multimedia.

  What is your all-time favorite linux-related website

What is your all-time favorite Linux-related website? Why is it your favorite (reference, utility, comic relief, etc.)?

  Determine the number of students having scores

Write a program that reads a file ("scores.txt") consisting of students' test scores in the range of 0-200. These scores should be loaded into a one-dimensional array. Then the program should determine the number of students having scores in each ..

  Create a powerpoint presentation to present the findings

Create a PowerPoint presentation to present the findings of your research to the widget company that has hired you as a consultant. Use five or more slides that detail the recommendations you are making to the company executives.

  Boolean variable called wantstoppings

After reading the input character, the program shall assign a value to a Boolean variable called  wantsToppings ( true  for a customer who wants toppings,  false  for a customer who does not).

  Search the web for steganographic tools

Search the Web for steganographic tools.

  Input boxes control element text numerical entry true false

Input boxes are a form control element used for text and numerical entries. True False

  Project 2 this assignment consists of two 2 sections a

this assignment consists of two 2 sections a business requirements document and a gantt chart or project plan. you must

  Create a class called book defines properties title

1. Create a class called Book defines properties Title, Author and Year.  Add a method called Display() that outputs the Title and Author 2. Create a class called BookTest that uses an object initializer to create an object of class Book (from step 1..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd