Modify the program below, by adding an option 'f' to your menu program. If this option is chosen, the program should ask the user to enter 10 integers. The program should store each integer into an array (as each one is entered). Once the array contains the 10 integers, the program should output: - The sum of the 10 numbers entered - The average of the 10 numbers entered - The highest number entered - The lowest number entered import java.util.*; public class Code { static Scanner scan = new Scanner(System.in); public static int bigger(int x, int y, int z) { int large = x; if(x >= y && x >= z) large = x; else if(y>=x && y >=z) large = y; else large = z; return large; } public static int smaller(int x, int y, int z) { int small = x; if(x <= y && x <= z) small = x; else if(y<=x && y <=z) small = y; else small = z; return small; } public static void bigSmall() { System.out.print("Enter three numbers: "); int x = scan.nextInt(); int y = scan.nextInt(); int z = scan.nextInt(); System.out.println("Largest Number is " + bigger(x,y,z)); System.out.println("Smallest Number is " + smaller(x,y,z)); } public static void numList() { System.out.print("Enter two numbers: "); int m = scan.nextInt(); int n = scan.nextInt(); int count = 0; int sumOdd = 0; int i; for(i=m; i<=n; ++i) { System.out.print(i + " "); ++count; if(count==5) { System.out.println(); count = 0; } if(i%2 != 0) sumOdd = sumOdd + i; } System.out.println(); System.out.println("Sum of odd numbers between " + m + " and " + n + " is " + sumOdd); } public static void isTriangle() { System.out.print("Enter three sides of triangle: "); int a = scan.nextInt(); int b = scan.nextInt(); int c = scan.nextInt(); String res = ""; if(!((a+b) > c && (b+c) > a && (a+c) > b)) res = "not"; System.out.println("The three sides " + a + ", " + b + ", " + c + " can" + res + " form a triangle"); } public static void isPrime() { System.out.print("Enter a number: "); int n = scan.nextInt(); int i; boolean prime = true; if(n<2) prime = false; else { for(i=2; i<(n/2); ++i) { if(n%i == 0) { prime = false; break; } } } if(prime) System.out.println(n + " is a Prime number"); else System.out.println(n + " is not a Prime number"); } public static void main(String[] args) { System.out.print("Enter a character: "); char in = scan.next().toLowerCase().charAt(0); loop: while (in != 'q') { switch(in) { case 'a': System.out.println("Name"); System.out.println("Tutor's Name"); break; case 'b': bigSmall(); break; case 'c': numList(); break; case 'd': isTriangle(); break; case 'e': isPrime(); break; case 'q': break loop; default: System.out.println("Invalid Character. Please re-try OR type 'q' to exit"); break; } System.out.print("Enter a character: "); in = scan.next().toLowerCase().charAt(0); } } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Modify the program below, by adding an option 'f' to your menu
program. If this option is chosen, the program should ask the user to enter 10
integers. The program should store each integer into an array (as each one is
entered). Once the array contains the 10 integers, the program should output:
- The sum of the 10 numbers entered
- The average of the 10 numbers entered
- The highest number entered
- The lowest number entered

import java.util.*;

public class Code {
static Scanner scan = new Scanner(System.in);
public static int bigger(int x, int y, int z) {
int large = x;
if(x >= y && x >= z)
large = x;
else if(y>=x && y >=z)
large = y;
else
large = z;
return large;
}

public static int smaller(int x, int y, int z) {
int small = x;
if(x <= y && x <= z)
small = x;
else if(y<=x && y <=z)
small = y;
else
small = z;
return small;
}

public static void bigSmall() {
System.out.print("Enter three numbers: ");
int x = scan.nextInt();
int y = scan.nextInt();
int z = scan.nextInt();
System.out.println("Largest Number is " + bigger(x,y,z));
System.out.println("Smallest Number is " + smaller(x,y,z));
}

public static void numList() {
System.out.print("Enter two numbers: ");
int m = scan.nextInt();
int n = scan.nextInt();
int count = 0;
int sumOdd = 0;
int i;
for(i=m; i<=n; ++i) {
System.out.print(i + " ");
++count;
if(count==5) {
System.out.println();
count = 0;
}
if(i%2 != 0)
sumOdd = sumOdd + i;
}
System.out.println();
System.out.println("Sum of odd numbers between " + m + " and " + n + " is " + sumOdd);
}

public static void isTriangle() {
System.out.print("Enter three sides of triangle: ");
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
String res = "";
if(!((a+b) > c && (b+c) > a && (a+c) > b))
res = "not";
System.out.println("The three sides " + a + ", " + b + ", " + c + " can" + res + " form a triangle");
}

public static void isPrime() {
System.out.print("Enter a number: ");
int n = scan.nextInt();
int i;
boolean prime = true;
if(n<2)
prime = false;
else {
for(i=2; i<(n/2); ++i) {
if(n%i == 0) {
prime = false;
break;
}
}
}
if(prime)
System.out.println(n + " is a Prime number");
else
System.out.println(n + " is not a Prime number");
}

public static void main(String[] args) {
System.out.print("Enter a character: ");
char in = scan.next().toLowerCase().charAt(0);
loop:
while (in != 'q') {
switch(in) {
case 'a':
System.out.println("Name");
System.out.println("Tutor's Name");
break;
case 'b':
bigSmall();
break;
case 'c':
numList();
break;
case 'd':
isTriangle();
break;
case 'e':
isPrime();
break;
case 'q':
break loop;
default:
System.out.println("Invalid Character. Please re-try OR type 'q' to exit");
break;
}
System.out.print("Enter a character: ");
in = scan.next().toLowerCase().charAt(0);
}
}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education