Question: For this assignment you will want to create 2 files called RunMyMethods and MyMethods The first file RunMyMethods will contain the main that calls a
For this assignment you will want to create files called "RunMyMethods" and MyMethods The first file RunMyMethods will contain the main that calls a menu method and will have a loop structure that will allow a user to choose what program they want to run. The menu displayed will look like this:
Product no negatives
Find Twelve
Max Min Avg
Letter Grade
Custom Method you design and name
Exit
The second file MyMethods will have methods in it that correspond to the menu shown above. The methods should do the following:
Write a program that will find the product of a collection of data values. The program should ignore all negative values, not convert negative values to positive. For Example if I enter in the answer would be not positive
Write a program to read in a collection of integer values, and find and print the index of the first occurrence and last occurence of the number The program should print an index value of if the number is not found. The index is the sequence number of the data item For example if the eighth data item is the only then the index value should be printed for the first and last occurrence.
Write a program to find the minimum, maximum, and average values of a collection of data values. The number of data values is unspecified.
Write a program to read in a collection of exam scores ranging in value from to The program should count and print the number of As to Bs to Cs to Ds to and Fs to The program should also print each score and its letter grade. The following is an example of test data you could enter, but feel free to enter any data you like:
Think of a creative method that you can do for yourself. Calculating baseball averages, golf handicaps, or a fortune teller app based on your fa
public class MyMethods
public void productNoNegative
System.out.printlnI am in prod no negative";
public void findTwelve
System.out.printlnI am in find twelve";
public void maxMinAvg
System.out.printlnI am in max min avg";
public void grades
package umsl.edu;
import java.util.Scanner;
@author swimc
public class RunMyMethods
public static void mainString args
Scanner sc new ScannerSystemin;
MyMethods mm new MyMethods;
rmmmenu;
public void menu throws IOException
MyMethods mm new MyMethods;
Scanner sc new ScannerSystemin;
int input ;
do
System.out.println Prod no negative";
System.out.println Find Twelve";
System.out.println Max min avg";
System.out.println Grades";
System.out.println Fortune teller";
System.out.println Exit";
input scnextInt;
ifinput
mmproductNoNegative;
productNoNegative;
else ifinput
mmfindTwelve;
else ifinput
mmmaxMinAvg;
else ifinput
mmgrades;
else ifinput
whileinput ;
package umsl.edu;
public class MyMethods
Method to find the product of a collection of data values ignoring negatives
public static int productNoNegativesint data
int product ;
for int value : data
if value
product value;
return product;
Method to find the first and last occurrence indices of the number
public static int findTwelveIndicesint data
int firstIndex ;
int lastIndex ;
for int i ; i data.length; i
if datai
if firstIndex
firstIndex i ; Convert to based index
lastIndex i ;
return new int firstIndex, lastIndex ;
Method to find the minimum, maximum, and average values
public static double minMaxAvgint data
if datalength
return new double Double.NaN, Double.NaN, Double.NaN ;
int min data;
int max data;
int sum ;
for int value : data
min Math.minmin value;
max Math.maxmax value;
sum value;
double avg double sum data.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
