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 2 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:
1) Product no negatives
2) Find Twelve
3) Max Min Avg
4) Letter Grade
5) Custom Method ( you design and name)
6) Exit
The second file MyMethods will have methods in it that correspond to the menu shown above. The methods should do the following:
1.
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 2-34 the answer would be 8 not positive 24.
2.
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 12. The program should print an index value of 0 if the number 12 is not found. The index is the sequence number of the data item 12. For example if the eighth data item is the only 12, then the index value 8 should be printed for the first and last occurrence.
3.
Write a program to find the minimum, maximum, and average values of a collection of data values. The number of data values is unspecified.
4.
Write a program to read in a collection of exam scores ranging in value from 0 to 100. The program should count and print the number of A's (90 to 100), B's (70 to 89), C's (50 to 69), D's (35 to 49) and F's (0 to 34). 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:
637572727867806309089435999821210075
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.println("I am in prod no negative");
}
public void findTwelve()
{
System.out.println("I am in find twelve");
}
public void maxMinAvg()
{
System.out.println("I am in max min avg");
}
public void grades()
{
}
}
package umsl.edu;
import java.util.Scanner;
/**
*
* @author swimc
*/
public class RunMyMethods
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
MyMethods mm = new MyMethods();
rmm.menu();
}
public void menu() throws IOException
{
MyMethods mm = new MyMethods();
Scanner sc = new Scanner(System.in);
int input =0;
do
{
System.out.println("1) Prod no negative");
System.out.println("2) Find Twelve");
System.out.println("3) Max min avg");
System.out.println("4) Grades");
System.out.println("5) Fortune teller");
System.out.println("6) Exit");
input = sc.nextInt();
if(input ==1)
{
mm.productNoNegative();
//productNoNegative();
}
else if(input ==2)
{
mm.findTwelve();
}
else if(input ==3)
{
mm.maxMinAvg();
}
else if(input ==4)
{
mm.grades();
}
else if(input ==5)
{
}
}while(input !=6);
}
}
package umsl.edu;
public class MyMethods {
// Method to find the product of a collection of data values (ignoring negatives)
public static int productNoNegatives(int[] data){
int product =1;
for (int value : data){
if (value >=0){
product *= value;
}
}
return product;
}
// Method to find the first and last occurrence indices of the number 12
public static int[] findTwelveIndices(int[] data){
int firstIndex =-1;
int lastIndex =-1;
for (int i =0; i < data.length; i++){
if (data[i]==12){
if (firstIndex ==-1){
firstIndex = i +1; // Convert to 1-based index
}
lastIndex = i +1;
}
}
return new int[]{ firstIndex, lastIndex };
}
// Method to find the minimum, maximum, and average values
public static double[] minMaxAvg(int[] data){
if (data.length ==0){
return new double[]{ Double.NaN, Double.NaN, Double.NaN };
}
int min = data[0];
int max = data[0];
int sum =0;
for (int value : data){
min = Math.min(min, value);
max = Math.max(max, 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!