Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) In your main method, write the code that will display Welcome to ITSC1213 five times using a for loop. 2) Create a

1)

In your main method, write the code that will display "

Welcome to ITSC1213

" five

times

using a for loop.

2)

Create

a new method:

public static int sumForLoop(int[] numbers)

This method should return the sum of all the elements in the parameter array. Test this

in your main method by creating an array of integers, calling

sumForLoop with the array you created, and print out the result of sumForLoop

Create a new method:

public static int findMax(int[] numbers)

This method should return the largest number in the array of

ints

. Test this in your

main method by creating an array of integers, calling

findMax

, and printing the result.

Make sure this method will work with

any

array

of integers, even ones with all negative

numbers.

1)

Create

a new method:

public static boolean stringsEqual(String a,

String b)

a.

This function should return true if the two string parameters are the same string

of characters

. You should loop through the strings and

use the

charAt()

method

to test if each character is equal to the other String's character.

Do not

use the String

equals()

method for this and do not use "a == b" for this.

Test

this method in the main method by cr

eating two Strings, calling

stringsEqual

with both Strings as parameters, and printing the result of

stringsEqual

.

2)

Create

a new method in

Main.java: public static int

findFirstOdd(int[] numbers).

a.

This method should return the first odd number in an array, or return 0 if no odd

numbers were found. Use a

while

loop to find the first odd number in an array.

When you find one, stop looping and return the odd number. Test this by

passing the method seve

ral integer arrays. Remember to test with an array that

contains no odd numbers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions