Write a program that reads a list of integers, and outputs whether the list contains all multiples of 10, no multiples of 10, or mixed values. Define a method named isArrayMult10 that takes an array as a parameter, representing the list, and an integer as a parameter, representing the size of the list. isArrayMult10() returns a boolean that represents whether the list contains all multiples of ten. Define a method named isArrayNoMult10 that takes an array as a parameter, representing the list, and an integer as a parameter, representing the size of the list. isArrayNoMult10(0 returns a boolean that represents whether the list contains no multiples of ten. Then, write a main program that takes an integer, representing the size of the list, followed by the list values. The first integer is not in the list. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 20 40 60 80 100 the output is: all multiples of 10 Ex: If the input is: 5 11 -32 53 -74 95 the output is: no multiples of 10 Ex: If the input is: 5 10 25 30 40 55 the output is: mixed values The program must define and call the following two methods. isArrayMult10) returns true if all integers in the aray are multiples of ten and false otherwise. İsArrayNoMult10) returns true if no integers in the array are multiples of ten and false otherwise. public static boolean isArrayMult10 (int[] arrayValues, int arraySize) public static boolean iSArravNoMult10(int[1 arravvalues, int arravSize)
import java.util.Scanner;
public class LabProgram
{
static boolean IsArrayMult10(int inputVals[],int numVals)
{
for(int i=0;i<numVals;i++)
{
if(inputVals[i]%10!=0)
return false;
}
return true;
}
static boolean IsArrayNoMult10(int inputVals[],int numVals)
{
for(int i=0;i<numVals;i++)
{
if(inputVals[i]%10!=0)
return true;
}
return false;
}
public static void main(String[] args)
{
int n;
boolean f=false;
Scanner sc= new Scanner(System.in);
n=sc.nextInt();
int []arr=new int[20];
if(n<=20)
{
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
}
if(IsArrayMult10(arr,n)==true)
System.out.print("all multiples of 10\n");
if(IsArrayNoMult10(arr,n)==true)
{
for(int i=0;i<n;i++)
{
if(arr[i]%10==0)
{
f=true;
break;
}
}
if(f==true)
System.out.println("mixed values");
else
System.out.println("no multiples of 10");
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images