Write a
5
12
3
5
5
3
21
−1
then the program should output the following (not necessarily in this order):
The number 5 occurs 2 times.
The number 5 occurs 3 times.
The number 12 occurs 1 times.
The number 21 occcrs 1 times.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Introduction to Programming Using Visual Basic (10th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Python (3rd Edition)
- Java Programming: Write a program that reads five integer values from the user, then analyzes them as if they were a hand of cards. When your program runs it might look like this (user input is in orange for clarity): Enter five numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: 8 Card 4: 2 Card 5: 9 Pair! (This is a pair, since there are two eights). You are only required to find the hands Pair and Straight.arrow_forwardLab Activity: In python.arrow_forwardUsing Javascript and HTML: An interesting application of computers is drawing graphs and bar charts (sometimes called histograms). Write a script that reads five numbers between 1 and 30. For each number read, output HTML5 text that displays a line containing the same number of adjacent asterisks. For example, if your program reads the number 5, it should out HTML5 test that displays *****.arrow_forward
- Solve using Javaarrow_forwardSolve TriangleProblem3.java. You may need more than one pair of nested loops.arrow_forwardWrite a program that finds word differences between two sentences. The input begins with the first sentence and the following input line is the second sentence. Assume that the two sentences have the same number of words. The program displays word pairs that differ between the two sentences. One pair is displayed per line. Ex: If the input is: Smaller cars get better gas mileage Tiny cars get great fuel economy then the output is: Smaller Tiny better great gas fuel mileage economy Hint: Store each input line into a list of strings.arrow_forward
- Write a program that picks four cards from a deck of 52 cards and computes their sum. An ace, king, queen, and jack represent 1, 13, 12, and 11, respectively. Your program should display the number of picks that yieldthe sum of 24.arrow_forwardIn cpp Room contains nx n cubes (in rows and in columns). Each cube is white or black. You can get out of a white cube by going in one of the four directions horizontally or vertically (but you can't go outside the room). You can enter a black cube, but you can't exit it. There is a mouse and a piece of cheese in the room. The mouse is in a cube (0,0) - white, and the cheese in a cube (n-1, n-1) - black. The mouse can move from cube to cube according to the rules described above. Write a program that finds all the ways in which the mouse can move to the cheese, and if any, display it with ‘*’.arrow_forwardPython For this lab, you will use a tuple to represent a student record. A student record consists of the student’s name, year, and GPA. For example, (“John”, “Senior”, 3.7) is a record for John who is a senior with a 3.7 GPA. You will write a program that prompts the user for the number of records to enter. Then it reads input from the user for each record. Remember that each record consists of a student’s name, year, and GPA. It then prints the record of each student as shown below. Functions: You will write the following functions: read_records(n) Read n number of records and return a list of records. print_records(records) Takes in a list of records and print each one. main() Prompts the user for the number of records to read, get a list of records from the user, and print the records. Optional: print the average GPA of the students. Sample run: How many students record to enter: 2 Enter student's name: John Enter student's year: junior Enter…arrow_forward
- write a java program A twin prime is a prime number that is either 2 less or 2 more than another prime number. For example (41, 43) are both primes and are twin primes because 41 + 2 = 43. Write a program that asks the user to enter a positive number and checks if this number is prime. If the number is prime then the program must check if it has a twin prime. So if n is prime, then n - 2 or n + 2 should be checked. The program repeats until the user enters -1. Sample Run: Enter a positive integer (-1 to end): -5 Invalid Number Enter a positive integer (-1 to end): 61 61 is prime 59 and 61 are twin prime Enter a positive integer (-1 to end): 137 137 is prime 137 and 139 are twin prime Enter a positive integer (-1 to end): 30 30 is not prime Enter a positive integer (-1 to end): 23 23 is prime 23 does not have a twin prime Enter a positive integer (-1 to end): -1arrow_forwardJavaarrow_forwardPython Scrabble is a word game in which words are constructed from letter tiles, each letter tile containing a point value. The value of a word is the sum of each tile's points added to any points provided by the word's placement on the game board. Write a program using the given dictionary of letters and point values that takes a word as input and outputs the base total value of the word (before being put onto a board). Ex: If the input is: PYTHON the output is: 14 part of the code: tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 }arrow_forward
- 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