I. Create a program that uses an anray to store the results from a poll of 25 pe
ID: 3748990 • Letter: I
Question
I. Create a program that uses an anray to store the results from a poll of 25 people. Each person was each day. The asked to estimate the amount of time, in minutes, that he or she spends on program should allow the user to enter a specific number of minutes and then display the number of people spending more than that length of time. int pol Results [25] -[35 15, 10, 25, 60, 100, 90, 10, 120, 5, 40, 70, 30, 25, 5 , 120, 75, 60, 20, 25, 15, 90, as, 35, 60, whe spend more than 48 minutes day on Facebook: 11 Create a program that comverts the number of American dollars entered by the user imto one of the following foreign currencies: B select the foreign currency from a menu. Store the exchange rates in a four-element double array named rates. The array is illustrated below and includes the exchange rates the program should 2. euro, British pound, Gierman mark, or Swiss franc. Allow the user to rate. For example, menu choice I's rate is stored in the array element whose subscript is . rates[0] 0.92 rates(1) rates[21 rates(3) 0.98 1.81 0.67 3. Create a program that displays the highest namber stored in a four-element array. The amay contains the following nambers: 13, 2, 40, and 25. Use a program-defined value-returning funetion to determine the highest number.Explanation / Answer
Hi Student as you didn't provide the programming language name so i am providing answer most common and efficient language Java.
Q1.
import java.util.Scanner;
public class CheggArray1 {
public static void main(String[] args) {
//Enter array of size 25
int pollResult[]={35,120,75,60,20,25,15,90,85,35,60
,15,10,25,60,100,90,10,120,5,40,70,30,25,5};
Scanner in=new Scanner(System.in);
System.out.print("Search for minutes over:");
int a=in.nextInt();
int count=0;
//Iterate through array and calculate
for(int i:pollResult){
//Increse count if more than specified time
if(i>a)
count++;
}
System.out.println("Number of people who spend more than "+a+" minutes per day"
+ "on facebook is :"+count);
}
}
Output:
Search for minutes over:40
Number of people who spend more than 40 minutes per dayon facebook is :11
Q2.
import java.util.Scanner;
public class CheggArray2 {
public static void main(String[] args) {
//Enter array of size 25
Scanner in=new Scanner(System.in);
System.out.print("Enter American Dollar :$");
double a=in.nextDouble();
//Take input from user
//Allow user to choose from menu
System.out.println("Convert to other Currency");
System.out.println("For Euro press 1");
System.out.println("For British Pound press 2");
System.out.println("For German mark press 3");
System.out.println("For Swiss Frank press 4");
int choice=in.nextInt();
//intialize array rates
double rates[]=new double[4];
//Store exchange rate in array
rates[0]=0.92;
rates[1]=1.81;
rates[2]=0.98;
rates[3]=0.67;
switch(choice){
case 1:
//Calculate and print based on selection
System.out.println("Equivalent euro is "+rates[0]*a);
break;
case 2:
System.out.println("Equivalent British pound is "+rates[1]*a);
break;
case 3:
System.out.println("Equivalent German mark is "+rates[2]*a);
break;
case 4:
System.out.println("Equivalent Swiss Frank is "+rates[3]*a);
break;
}
}
}
Output:
Enter American Dollar :$50
Convert to other Currency
For Euro press 1
For British Pound press 2
For German mark press 3
For Swiss Frank press 4
1
Equivalent euro is 46.0
Q3.
public class CheggArray3 {
public static void main(String[] args) {
//create array of int containing 4 int
//Store specified number in array
int array[]={13,2,40,25};
//Call max() method to find maximumnumber
int mx=max(array);
System.out.println("The maximun number in array is :"+mx);
}
//method to find maximum number
public static int max(int[] arr){
int mx=0;
//Find maximum number
for(int a :arr){
if(a>mx)
mx=a;
}
//return result
return mx;
}
}
Output:
The maximun number in array is :40