C++ please
Possible algorithms – (1) use and modify the algorithm from program 2 if possible; (2) use unique value array; (3) use flag array (flags used to avoid counting a number more than 1 time); (4) compute frequency distribution (use unique and count arrays); (5) use count array to store the frequency of a number.
No global variable are permitted in this assignment. Do not change the code provided only write the missing code. Write the missing C++ statements in the code above to complete the program
User will enter a value (dsize) which represents the number of values to process
user enters size numbers in the range of -2147483648 to 2147483647
The values entered will be stored in an array of type long that has 10,000 elements
User will enter a frequency of choice (Frequency, such as 5, or 2500, etc.)
program will count and display the number of values in the array which occurred exactly Frequency times
and display the specific numbers/values which occurred with the user entered value for the Frequency
Examples using a value of 5 for the required frequency
Example: 2, 3, 4, 3, 3, 5, 2, 9, 5 number of values with a frequency of 5 is 0
Example: 10, 1, 8, 5, 1, 5, 4, 1, 5, 1, 1, 1 occurred with a frequency of 5
Example: 10, 11, 11, 3, 10, 10, 10, 11, 10, 11, 11 10 and 11 occurred with a frequency of 5
*/
#include<iostream> // required header file for input/output
using namespace std;
// prototypes you must use for this assignment
void input_data(long data[], short size);
void display_data (long data[], short size);
short countOfFrequency (long data[], short size, long FreqNumbers[ ], short Frequency);
int main()
{ // declare local variables
long data[10000], FreqNumbers[10000];
short dsize, Fsize, Frequency; // list may not be complete
// display a message to the user about the number of values to store in the array
cin>>dsize;
while (dsize > 0) //pretest loop - will execute while size > 0
{
// output a message to enter the values to be processed
// call the input_data function
// print a message about the number of values stored in the array
// call the display_data function
// print a message to the user that program will count the number of values which occurred in the array for a
// frequency of their choice; ask use to enter a frequency of their choice.
cin>> Frequency;
while (Frequency > 0) // loop to check more than 1 frequency but only 1 at a time
{
// call countOfFrequency function
// display a message about the number of values in the FreqNumbers array which occurred exactly Frequency times
// call the display_data function to print the values stored in the FreqNumbers array
// this function should not be called if no values occurred with the required frequency
// print a message to user that program will count the number of values which occurred in the array for a frequency
// of their choice; ask user to enter a frequency of their choice or 0 to terminate the loop.
cin>>Frequency;
}// end of inner while loop
cout<<"To run the program again, enter the number of values to store in the array or 0 to terminate the program ";
cin>>dsize;
}// end of outer while loop
// pause the program to see the results
//system("pause"); // this is a windows command; will not work in another operating system
// return 0; // optional statement, may be required for .NET compiler
}
//function definitions are placed after main
// Function to display the data in the array
// print all values on the same line with one space between each number
void display_data(long data[], short size)
{ /*code in function*/ }
// Do not output anything in the functions below
// Function to input(store) data into the array
void input_data(long data[], short size)
{ /*code in function*/}
//Function to return the count of the number of values which occurred exactly Frequency times
// store in the FreqNumbers array the actual values which occurred with a specific frequency
// Look at the last example above, you would store the values of 10 and 11 if the requested frequency was 5.
// If the requested frequency was 1 you would store a 3 in the FreqNumbers array.
short countOfFrequency (long data[], short dsize, long FreqNumbers[ ], short Frequency)
{ /*code in function*/}
If you have any doubts, please give me comment...
#include <iostream> // required header file for input/output
using namespace std;
// prototypes you must use for this assignment
void input_data(long data[], short size);
void display_data(long data[], short size);
short countOfFrequency(long data[], short size, long FreqNumbers[], short Frequency);
int main()
{ // declare local variables
long data[10000], FreqNumbers[10000];
short dsize, Fsize, Frequency; // list may not be complete
// display a message to the user about the number of values to store in the array
cout << "Enter number of values to store in the array: ";
cin >> dsize;
while (dsize > 0) //pretest loop - will execute while size > 0
{
// output a message to enter the values to be processed
cout << "Enter values to processed: ";
// call the input_data function
input_data(data, dsize);
// print a message about the number of values stored in the array
cout << dsize << " values stored in the array" << endl;
// call the display_data function
display_data(data, dsize);
// print a message to the user that program will count the number of values which occurred in the array for a
// frequency of their choice; ask use to enter a frequency of their choice.
cout << "Enter a frequency: ";
cin >> Frequency;
while (Frequency > 0) // loop to check more than 1 frequency but only 1 at a time
{
// call countOfFrequency function
int count = countOfFrequency(data, dsize, FreqNumbers, Frequency);
// display a message about the number of values in the FreqNumbers array which occurred exactly Frequency times
cout << count << " values in the Frequency numbers array which occured exactly " << Frequency << " times"<<endl;
// call the display_data function to print the values stored in the FreqNumbers array
if (count != 0)
display_data(FreqNumbers, count);
// this function should not be called if no values occurred with the required frequency
// print a message to user that program will count the number of values which occurred in the array for a frequency
// of their choice; ask user to enter a frequency of their choice or 0 to terminate the loop.
cout << "Enter a frequency or 0 to terminate: ";
cin >> Frequency;
} // end of inner while loop
cout << "To run the program again, \nenter the number of values to store in the array \nor 0 to terminate the program ";
cin >> dsize;
} // end of outer while loop
// pause the program to see the results
//system("pause"); // this is a windows command; will not work in another operating system
// return 0; // optional statement, may be required for .NET compiler
}
//function definitions are placed after main
// Function to display the data in the array
// print all values on the same line with one space between each number
void display_data(long data[], short size)
{
for(int i=0; i<size; i++){
cout<<data[i]<<" ";
}
cout<<endl;
}
// Do not output anything in the functions below
// Function to input(store) data into the array
void input_data(long data[], short size)
{
for(int i=0; i<size; i++){
cin>>data[i];
}
}
//Function to return the count of the number of values which occurred exactly Frequency times
// store in the FreqNumbers array the actual values which occurred with a specific frequency
// Look at the last example above, you would store the values of 10 and 11 if the requested frequency was 5.
// If the requested frequency was 1 you would store a 3 in the FreqNumbers array.
short countOfFrequency(long data[], short dsize, long FreqNumbers[], short Frequency)
{
short k = 0;
for(int i=0; i<dsize; i++){
int count = 0;
for(int j=i; j<dsize; j++){
if(data[i]==data[j]){
count++;
}
}
if(count==Frequency){
FreqNumbers[k] = data[i];
k++;
}
}
return k;
}
C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible;...
program will enter data into two single dimension arrays (do not store duplicate values in arrays) program will find the union and intersection of the two arrays using one function program will find the symmetric difference of two arrays program will display the union, intersection, and symmetric difference */ short* input_data(short size); // function to dynamically allocate and array and enter data into the array void display_data(short *data, short size); // function to display data in an array void get_union_intersection(short...
c++ please no global varaible write a value returning function input data to dynamically allocate a short array of size elements and store the input data entered from the disk file into array.Return the base address of the array allocated.Read the data from the text file Hello.txt and store the data in reverse order in the array.the size of the data set will be in the file size 10 and the data was 1 2 3 4 5 6 7...
C++ Program Int Main First Please Write one program that does the following: 1. 1. Ask the user for ten (10) grades, and store the data in an array. Compute the average of all the grades. Print the original ten grades and the average. a. Declare an integer array with the name of “grades” of size 10 in the main function. b. Create a function called “getGrades” that prompts the User for the grades and puts them in an integer array. i. The function will receive...
Topics c ++ Loops While Statement Description Write a program that will display a desired message the desired number of times. The program will ask the user to supply the message to be displayed. It will also ask the user to supply the number of times the message is to be displayed. It will then display that message the required number of times. Requirements Do this assignment using a While statement. Testing For submitting, use the data in the...
Can you fix this program and run an output for me. I'm using C++ #include using namespace std; //function to calculate number of unique digit in a number and retun it int countUniqueDigit(int input) { int uniqueDigitCount = 0; int storeDigit = 0; int digit = 0; while (input > 0) { digit = 1 << (input % 10); if (!(storeDigit & digit)) { storeDigit |= digit; ...
In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...
Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp Is posted here: // This program reads data from a file into an array. Then, it // asks the user for a number. It then compares the user number to // each element in the array, displays the array element if it is larger. // After looking at entire array, it displays the number of elements in the array larger // than the user...
use C++ to write the following program. needs to ask the user for n The user must put in those 5 values, probably using a for loop. NOTE: You can assume the number of values to be entered is 5. My attempted program below: (not correct, but just a basis) 4. Larger Than n In a program, write a function that accepts three arguments: an array, the size of the array, and a number n. Assume that the array contains...
The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...
Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...