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

  Disadvantages of allowing employees of an organization

Consider two (2) advantages and two (2) disadvantages of allowing employees of an organization, other than systems administrators and security personnel, to create and modify group policy objects in an organization and whether you believe the advanta..

  Create class savingsaccount

Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingBalance indicating the amount that saver currently..

  How the data block information is managed using fat

File X has 15 data blocks. The block addresses of the 15 blocks are 8, 9, 10, 11, 12, 13, 5, 4, 21, 22, 23, 24, 25, 26 and 27.

  Write quickest and easiest way to recover data

What is the quickest and easiest way to solve most urgent problem, recovering data? Write the major steps in that process.

  Uwb-based products

Discuss how Ultra Wide Band (UWB) works, and where it is used today in the real-world. What companies are making UWB-based products

  A common theme emerging from the group postings?

Is there a common theme emerging from the group postings?

  Purpose and goals of the mobile self-service

Elaborate on the guidelines for how the self-service Website can be kept current as newer mobile devices are being introduced at a rapid rate and the design of the Website for mobile devices and the interfaces that are applicable to the mobile devic..

  Write a proof that uses this approach

An alternative proof of the irrationality of square root of 2 counts the number of 2's on the two sides of the equation 2n^2 = m^2 and uses the unique factorization of integers theorem to deduce a contradiction. Write a proof that uses this approa..

  Calculating total addressing capacity of computer system

A computer system uses 20-bit address bus and can address an 8-bit wide memory. The memory of this computer system contains 2 × 32 Kbytes ROM (ROM1, ROM2) and 2 × 16 Kbytes of RAM (RAM1 & RAM2).

  What are the benefits of using tangible interfaces

What are the benefits of using tangible interfaces compared with other interfaces like GUI, pen-based or gesture?

  Give the contents of register a after the execution

Give the contents of Register A after the execution of the following instructions: Data_1 EQU $FE Data_2 EQU 1 LDAA #Data_1 LDAB #Data_2 ABA

  Did have any difficulties in following this coding process

Did you have any difficulties in following this coding process?

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