Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 1: Clean Code & Revision Please answer all the questions otherwise don't answer... Question 1: Write a short Java method that counts the number

Homework 1: Clean Code & Revision

Please answer all the questions otherwise don't answer...

Question 1:

Write a short Java method that counts the number of vowels in a given string.

Question 2:

Given a valid IP(Internet Protocol) address as a string of the following format x.x.x.x where x is called an octet

and must be a decimal value between 0 and 255. Write a method that replaces every period "." with "[.]", and

returns the edited address.

Example Run:

Input: address = "1.1.1.1" , Output: "1[.]1[.]1[.]1"

Question 3:

Given an integer n, Write a method to perform the following conditional actions:

If n is odd, print Weird.

If n is even and in the inclusive range of 2 to 5, print Not Weird.

If n is even and in the inclusive range of 6 to 10, print Weird.

If n is even and greater than 10, print Not Weird.

Question 4:

Given an int array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]nums[i]).

Write a method that returns the running sum of nums.

Question 5:

Write a program that reads integer inputs from the user until the user presses q( Ask to press q to quit

after every integer input). Print average and product of all numbers.

Question 6:

Write a Java method, call it isMultiple, that takes two long values: n and m, and returns true if and only if n is a

multiple of m, that is, n = mi for some integer i.

Question 7:

Write a method that takes an integer number n, return the difference between the product of its digits and the

sum of its digits.

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

More Books

Students also viewed these Databases questions

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago