Using c++ Write a program that reads in a list of up to 25 first
names from an input file nameData.txt and
allows the user to display the name data, sort it in ascending or
descending order, count the
number of occurrences of a given name, or exit the program. The
input file consists of a single
names per line with each line terminated with an end of line (i.e.
using Enter key to end the line).
Your program should present the user with a menu that provides the
options show below in
INPUT/OUTPUT.
You must use the following enum for the menu selection:
enum MenuPick {READ_DATA, // Read names from file
DISPLAY, // Display names
SORT_ASC, // Sort names ascending
SORT_DEC, // Sort names descending
COUNT, // Count name
EXIT // Exit program
};
You must write a function with header
MenuPick getMenuPick()
to display the menu, validate the menu pick, and return the
enumerator associated with the
selected menu item. Your main function must then use the returned
enumerator to perform
the appropriate operation.
You must write a single bubble sort function with header
void bubbleSort(string strAr[], const int SIZE, const bool
ascending)
to perform the sorting and you must use a string method to perform
the array element swap
within your bubbleSort function (hint:
http://www.cplusplus.com/reference/string/string/swap/) .
You must write a counting function with header
int count(const string strAr[], const string key,const int SIZE)to
count the occurrences of a given name.
Both the sort and counting functions should be in a separate
source file functions.cpp with a
separate header file functions.h.
Test your program thoroughly, including using an input file with no
names and one with greater
than 25 names. The output below is for the sample input file
included.
Screen INPUT/OUTPUT - should be formatted as follows :
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:2
No names to display!
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:1
10 names read from file e:\nameData.txt
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:2
1: Joe
2: Sally
3: Joe
4: Sue
5: Sally
6: Adam
7: Joe
8: Adam
9: Adam
10: Joe
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:3
Sorting in ascending order...
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:2
1: Adam
2: Adam
3: Adam
4: Joe
5: Joe
6: Joe
7: Joe
8: Sally
9: Sally
10: Sue
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:4
Sorting in descending order...
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:2
1: Sue
2: Sally
3: Sally
4: Joe
5: Joe
6: Joe
7: Joe
8: Adam
9: Adam
10: Adam
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:1
10 names read from file e:\nameData.txt
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:2
1: Joe
2: Sally
3: Joe
4: Sue
5: Sally
6: Adam
7: Joe
8: Adam
9: Adam
10: Joe
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:5
Enter a name to count: Joe
Name Joe occurs 4 times
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:5
Enter a name to count: Sue
Name Sue occurs 1 time
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:7
Please enter a number between 1 and 6!
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:exit
Please enter an integer value!
Please select from one of the following options:
1. Read names from file
2. Display names
3. Sort names ascending
4. Sort names descending
5. Count name
6. Exit program
Selection:6
Thank you for using my name program.
nameData.txt file :
Joe
Sally
Joe
Sue
Sally
Adam
Joe
Adam
Adam
Joe
|
#include<iostream> enum MenuPick MenuPick getMenyPick(int choice) void readFile(string strArr[100], int &size, string
file) void printNames(string strArr[100], int size) } int main() while (true) return 0; |
|
#pragma once class Functions static void count(const string strAr[100], string key, int size); ~Functions(); |
|
#include "Functions.h"
bool Functions::Pass(string strArr[100], int size, bool
compare(string Name1, string Name2)) void Functions::bubbleSort(string strArr[100], int size, bool
compare(string Name1, string Name2)) void Functions::count(const string strAr[100], string key, int
size) Functions::~Functions() |


IF THERE IS ANY PROBLEM OR YOU HAVE ANY QUERY REGARDING THE SOLUTION KINDLY FEEL FREE TO ASK, AND LEAVE A THUMBS UP WHEN YOU ARE SATISFIED. THANKS!.
Using c++ Write a program that reads in a list of up to 25 first names...
Help in JAVA please Write a program that reads a list of students (first names only) from a file. It is possible for the names to be in unsorted order in the file but they have to be placed in sorted order within the linked list. The program should use a doubly linked list. Each node in the doubly linked list should have the student’s name, a pointer to the next student, and a pointer to the previous student. Here...
in c++
Program 1 Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions I. void selSort (vector string &v: sorts the vector using selection sort 2. void display (const vector <string & v): displays the vector contents . int binSearch (const vector <ing& v, string key): searches the vector for a key returns the...
.Using OOP, write a C++ program that will read in a file of names. The file is called Names.txt and should be located in the current directory of your program. Read in and store the names into an array of 30 names. Sort the array using the selection sort or the bubblesort code found in your textbook. List the roster of students in ascending alphabetical order. Projects using global variables or not using a class and object will result in...
Using Java Create an application that creates and displays a list of names using an array. Then modify the application to create and use a list of numbers. Console for the names application Please enter a name or type “exit” to quit: Diane Please enter a name or type “exit” to quit: Joe Please enter a name or type “exit” to quit: Greta Please enter a name or type “exit” to quit: Henry Please enter a name or type “exit”...
Must be written in C++ Display results and comments Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions: 1. void selSort (vector <string> & v): sorts the vector using selection sort 2. void display (const vector <string> & v): displays the vector contents 3. int binSearch (const vector <string> & v, string key): searches...
Written in Java Your job is to produce a program that sorts a list of numbers in ascending order. Your program will need to read-in, from a file, a list of integers – at which point you should allow the user an option to choose to sort the numbers in ascending order via one of the three Sorting algorithms that we have explored. Your program should use the concept of Polymorphism to provide this sorting feature. As output, you will...
Write a C program that reads a sequence of numbers and display a message 1. The numbers a re red from the standard input. 2. The first number is the length of the sequence (n) followed by n numbers. 3. If n is 0 or negative, the program displays the message "Error_1" followed 4. If the length is shorter than n, it displays "Error_2" followed by a new line 5. The program inspects the list and display one of the...
C++ programming language Write a program that asks the user for a file name. The file contains a series of scores(integers), each written on a separate line. The program should read the contents of the file into an array and then display the following content: 1) The scores in rows of 10 scores and in sorted in descending order. 2) The lowest score in the array 3) The highest score in the array 4) The total number of scores in...
-I need to write a program in C to store a list of names (the last name first) and age in parallel arrays , and then later to sort them into alphabetical order, keeping the age with the correct names. - Could you please fix this program for me! #include <stdio.h> #include <stdlib.h> #include <string.h> void data_sort(char name[100],int age[100],int size){ int i = 0; while (i < size){ int j = i+1; while (j < size){...
C++ Programming question
Problem: 5. Write a program that reads in a list of integers into an array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be...