Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a java program maxMinAvg.java to asked user to input positive integers to process count, maximum, minimum, and average or terminate the process with

1. Write a java program maxMinAvg.java to asked user to input positive integers to process count, maximum, minimum, and average or terminate the process with a negative integer. Use while or do-while. Sample Output: Enter positive integers (negative to terminate): 9 3 8 4 -1 -1 is for termination. Here is the result below: Number of positive integers is: 4 The maximum value is: 9 The minimum value is: 3 The average is 6.00

2. TwoParts.java For each of the problems below write a method that takes one int parameter. So factorial(int n), pennies(int days). In main(), ask the user to enter a number then call the methods passing the user entered number as argument.Input Validation: Do not accept an input that is less than 0, use a do-while loop

Use For loop in all of the methods below:

a. public static void factorial(int n) This method uses a for loop to print the factorial of the parameter n as shown below. Calling factorial(5) produces this output: 5 ! = 1 * 2 * 3 * 4 * 5 = 120 Note: Mathematicians define 0! = 1 b. public static void pennies(int days) This method calculates how much a person earns for the number of days specified in the parameter. Earned money is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The method should display a table showing how much money was earned for each day worked, as well as the total amount earned. The output should be displayed in dollars with two decimal places, not in pennies. If the number of days is 5: day $ 1 0.01 2 0.02 3 0.04 4 0.08 5 0.16 ----- 0.31

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_2

Step: 3

blur-text-image_3

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

Overcome many cross-cultural communication barriers.

Answered: 1 week ago