Question
I need someone to write Pseudocode of the following C++ program. PLEASE DON'T ANSWER IF U DON'T KNOW ABOUT PSEUDOCODE. I don't want to write
I need someone to write Pseudocode of the following C++ program. PLEASE DON'T ANSWER IF U DON'T KNOW ABOUT PSEUDOCODE. I don't want to write each line, just the 11 methods and main function.
#include
using namespace std;
class Assignment4 { public: int numArray; int numbers[10001];
//Ouput All Values void OuputAll() { cout << "All Numbers: "; for (int count = 0; count < numArray; count++) { cout << numbers[count] << " "; } cout << endl; } //Sum of All Numbers void sumNumbers() { int sum = 0; for (int count = 0; count < numArray; count++) { sum += numbers[count]; } cout << "Total sum: " << sum << endl; } //All Even Numbers void evenNumbers() { cout << "All Even Numbers: "; for (int count = 0; count < numArray; count++) { if (numbers[count] % 2 == 0) { cout << numbers[count] << " "; }; } cout << endl; } //All Odd Numbers void oddNumbers() { cout << "All Odd Numbers: "; for (int count = 0; count < numArray; count++) { if (numbers[count] % 2 != 0) { cout << numbers[count] << " "; }; } cout << endl; } //Read Data from .TXT File void readData() { ifstream inputFile("File.txt"); if (inputFile.good()) { int current_number = 0; while (inputFile >> current_number) { numbers[numArray] = current_number; numArray = numArray + 1; } inputFile.close(); } else { cout << "File Not Open "; } }
//Find Middle number void middleNumber() { int firstIndex = 0; int endIndex = numArray - 1; int mid = firstIndex + (endIndex - firstIndex) / 2; if (mid < 0 || mid > endIndex) { cout << "Not A Valid Array" << endl; } else { cout << "Middle Numbers: " << numbers[mid] << endl; } } //Find First Value void firstValue() { int firstIndex = 0; cout << "First Value: "; cout << numbers[firstIndex] << endl; } //Find Last Value void lastValue() { cout << "Last Value: "; cout << numbers[numArray - 1] << endl; } //Find Highest Numbers and Location void highestValueAndLocation() { int max = -99999; int startIndex = 0; for (int count = 0; count < numArray; count++) { int temp = numbers[count]; if (temp > max) { max = temp; startIndex = count; } } cout << "Highest Numbers: " << max << " " << "Location (Index): " << startIndex << endl; } //Find Lowest Numbers and Location void lowestValueAndLocation() { int min = 99999; int startIndex = 0; for (int count = 0; count < numArray; count++) { int temp = numbers[count]; if (temp < min) { min = temp; startIndex = count; } } cout << "Lowest Numbers: " << min << " " << "Location (Index): " << startIndex << endl; } //Sorting By Bubble Sort void bubbleSort() { int data[numArray]; for (int j = 0; j < numArray; ++j) { data[j] = numbers[j]; } bool swap = true; int temp; while (swap) { swap = false; for (size_t i = 0; i < numArray - 1; i++) { if (data[i] > data[i + 1]) { //swapping elements at i and i+1 temp = data[i]; data[i] = data[i + 1]; data[i + 1] = temp; swap = true; } } } //Display Sorted Elements cout << "Sorted Data: "; for (size_t i = 0; i < numArray; i++) { cout << data[i] << " "; } cout << endl; } // Linear Search to search Any Element's location void searchElement(int dataToSearch) { bool flag = false; for (int count = 0; count < numArray; count++) { if (numbers[count] == dataToSearch) { cout << "Data Find At Location (Index): " << count << endl; flag = true; } } if (!flag) { cout << "Data Not Found In Given List: "; } cout << endl; } };
int main() { Assignment4 solution;
solution.readData(); solution.OuputAll(); solution.sumNumbers(); solution.oddNumbers(); solution.evenNumbers(); solution.middleNumber(); solution.firstValue(); solution.lastValue(); solution.highestValueAndLocation(); solution.lowestValueAndLocation(); solution.bubbleSort();
int Data; cout << "Enter Data To Search in List: "; cin >> Data; solution.searchElement(Data);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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