Question
Given a program that reads an arbitrary amount of integers between 0 - 50 from the user. Your program should count the number of times
Given a program that reads an arbitrary amount of integers between 0 - 50 from the user.
Your program should count the number of times each number was entered. Indicate the end of the user input by a value outside of the range.
After all input has been processed, print all of the values (with the number of occurrences) that were entered one or more times
Sample output: If the user enters 0 0 1 45 49 49 49 100
4. Given the following list of numbers [14, 17, 13, 15, 19, 10, 3, 16, 9, 12] What is the contents of the array after the second partition has occurred, according to the quicksort algorithm?
5. Write a file merge program There are two files numbers1.txt and numbers2.txt. Both of these files contain 500 integers (one integer per line). The integers in each file are sorted in nondescending order. Your program should read in the numbers from these files. Your program should then create a new output file. This file should contain the contents of the two input files, of the integers, still sorted in non-descending order
Challenge: try to do it without using built in sorts (i.e., don't just pour everything into one array and call sort)
Hint: you will probably want to create helper methods, and yes, there are exactly 500 ints in each file.
6. a method called rollDie that simulates the rolling of a single dice, i.e., returns a random number between 1 and 6.
Write a method that checks to see if the roll has won in the game of craps. ◦
- A loss is when the dice roll a 2, 3, or 12 ◦
- A win is when the dice roll 7 or 11 ◦
- All other numbers are a "tie"
Now wrote a main program that asks the user to bet whether the dice are going to "win" or "lose", and then roll a pair of dice using the rollDie method The program should then display what was rolled, check to see if the user bet correctly, and report the results
7.Give a method that accepts a string, str, and an integer, count, as parameters. The method should return a string that consists of str concatenated with itself count times.
ex. passing in "test" and 4, your method would return "testtesttesttest" /
Now overload your method so that if the integer parameter is not provided, the method returns the string concatenated with itself once ◦ ex. passing in "test" returns "test.
Step by Step Solution
3.42 Rating (165 Votes )
There are 3 Steps involved in it
Step: 1
Task 1 Counting User Input Well create a program to count the occurr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started