Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please this ! Problem #1: a- Write a method named isGreaterThan(int a, int b) that takes two integers a and b and checks whether a

image text in transcribed

please this !

Problem #1: a- Write a method named isGreaterThan(int a, int b) that takes two integers a and b and checks whether a is greater than b. The method returns true if a is greater than b. Otherwise it returns false. b- Write a program that prompts the user to enter a maxValue and a sequence of integers, the program ends when the user enters an integer larger than maxValue. It prints the sum of all the numbers excluding the max Value and indicates whether the sum is greater than the max Value. Sample Run 1: Enter a maximum number that stops the sequence: 25 Enter a sequence of numbers until the program terminates: 15 3 19 13 7 28 The sum is 85, the sum is greater than 25 Program terminated. Sample Run 2: Enter a maximum number that stops the sequence: 33 Enter a sequence of numbers until the program terminates: 35 The sum is 0, the sum is less than 33 Program terminated. 45 124 4 20 Problem #2: a) Write a method named display that accepts three numbers min, max and n. The method prints all numbers between min and max which are divisors of n and multiples of min. b) Write a program that prompts the user to enter 3 integer values min, max and n, then invokes the method display. If the user enters max before min (as in sample run2), the program swaps the values before calling the method. Sample runl: Enter 3 integer values min, max, and n: 2 Divisors of 124 in the range 2 - 45 and multiples of 2: 2 Sample run 2: Enter 3 integer values min, max, and n: 75 5 20 Divisors of 20 in the range 5 - 75 and multiples of 5: 5 10 Problem #3: Write a program that prompts the user to enter two integers m and n and displays the number of odd numbers between m and n inclusive (Assume m is always smaller than n). Your program should repeat as many times as the user wants (i.e. as long as the user did not enter the character value *n' as shown in the sample run below). Sample run: Enter two integers m and n (where m <>

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

Develop skills for building positive relationships.

Answered: 1 week ago

Question

Describe techniques for resolving conflicts.

Answered: 1 week ago

Question

Give feedback effectively and receive it appropriately.

Answered: 1 week ago