Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
java
Given an int [] nums, print true if the array has a 5 that is also next to another 5. Both conditions need to be met otherwise print false
Scanner input = new Scanner(System.in);
int[] nums = {input.nextInt(),input.nextInt(),input.nextInt(),input.nextInt(),input.nextInt()};
Input:
[1, 5, 5, 1, 1]
Output:
true
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 4 images
Knowledge Booster
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
- public class ArraySection { static void arraySection(int a[], int b[]) { int k = 0; int [] c = new int[a.length]; for(int i = 0; i < a.length; i++) { for(int j = 0; j < b.length; j++) if(a[i] == b[j]) c[k++] = a[i]; } for(int i = 0; i < k; i++) System.out.println(c[i]); System.out.println(); } public static void main(String[] args) { int a[] = { 1, 2, 3, 4, 5 }; int b[] = { 0, 2, 4,5 }; arraySection(a,b); }} Calculate the algorithm step number and algorithm time complexity of the above program?arrow_forwardCheck if Array Elements are Consecutive in Java. Given an array, we need to check if array contains consecutive elements. For example: Input: array[] = {5, 3, 4, 1, 2} Output: true As array contains consecutive elements from 1 to 5 Input: array[] = {47, 43, 45, 44, 46} Output: true As array contains consecutive elements from 43 to 47 Input: array[] = {6, 7, 5, 6} Output: false As array does not contain consecutive elements.arrow_forwardWrite a Java method (do not write a class, only the method) with the following signature: Return type: void Parameters: 2D integer array Name: printDiagonal Implement the method code that will print out the values of the 2D array along the Diagonal from left to right. For example, if the array had the following values: 56 78 98 21 33 55 98 44 11 The method should print to the console: 56,33,11 The above 2D array example is only given for you to understand the problem Do not hard code the values in your solution or assume the array is the same as the given data. Your method should work for all 2D integer arrays.arrow_forward
- THIS IS DONE IN JAVAarrow_forwardWrite a Java program with a single-dimension array that holds 10 integer numbers and identify the maximum value of the 10 numbers. Next sort the array using a bubble sort and display the array before and after sorting. Psuedocode Generate 10 random integer numbers between 1 and 100 place each random number in a different element of a single-dimension array Display the array's contents unsorted as they are generated Using the bubble sort, sort the array from smallest integer to the largest. //must use the following: Bubble Sort Code: public static void bubbleSort(int[] list) { int temp; for (int i = list.length - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (list[j] > list[j + 1]) { temp = list[j]; list[j] = list[j + 1]; list[j + 1] = temp; }…arrow_forwardpackage lab06;;public class gradereport { public static void main(String[] args) { Scanner in = new Scanner(System.in);double[] Scores = new double[10]; for(int i=0;i<10;i++){ System.out.println("Enter score " + (i+1));scores[i]=in.nextdouble(); } for(int i=0;i<10;i++){ if (scores[i] >=80) System.out.println("Score " + (i+1) + " receives a grade of HD"); else if (scores[i]>=70) System.out.println("Score " + (i+1) + " receives a grade of D"); else if (scores[i] >=60) System.out.println("Score "+ (i+1) + " receives a grade of C"); else if (scores[i] >=50) System.out.println("Score " + (i+1) + " receives a grade of P"); else if (scores[i] >=40) System.out.println("Score " + (i+1) + " receives a grade of MF"); else if (scores[i] >=0) System.out.println("Score " +…arrow_forward
- Write a Java program that reads an integer N from the user and declares an integer array of size N. It then inputs N non-negative integers from the user into the array and do the following: 1. Finds and prints the minimum, maximum, sum, and average of the numbers. 2. Displays array data as a histogram – graphically by plotting each numeric value as a bar of asterisks (+) as shown in the example diagram. This is somehow similar to Lab11 Sample output Enter the size of array: 9 Enter 9 integer values: 10 19 5 14 Minimum = Maximum = 19 = 68 = 7.55 Sum Average ========== Histogram: ======= Element Ua lue 10 19 Histogran T T T Arial v T = ABC 3 (12pt) II Comarrow_forwardimport java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int n = scnr.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = scnr.nextInt(); } for (int i = n - 1; i >= 0; i--) { System.out.print(arr[i]); if (i > 0) { System.out.print(","); } } }}arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education