==============C++ or java================
Write a modularized, menu-driven program to read a file with unknown number of records.
Create a class Records to store the following data: first and last name, GPA , an Id number, and an email
Input file has unknown number of records; one record per line in the following order: first and last names, GPA , an Id number, and email
All fields in the input file are separated by a tab (‘\t’) or a blank space (up to you)
No error checking of the data required; all records are unique
Store records in an array of objects
Create a menu which allows to
example
print records unsorted
sort by any field using array-based selection sort
sort by any field using array-based insertion sort
sort by any field using array-based quick sort
sort by any field using array-based bubble sort
quit the program and print a table of number of comparisons and the number of items movements for each sort performed
Sort Field Number of Comparisons Number of Items Movements
quick GPA 25 100
Before each sort, reload the array from the input function
After each sort, print the sorted array, number of comparisons, and the number of items movements
Write one function for each type of sort, that can sort by any field. Do not copy and paste body of sort code five times into the same function. The same body of the code should be able to handle sorting by any field based on the use choice. Start with bubble sort because it is the easiest to modify. To ensure that you write the sort code correctly, submit your bubble sort code here, as a Text Entry, before submitting the entire lab. This way I can let you if you have implemented the sort function correctly.
A user should be able to run many as many times as user wants
NO goto, continue, while(true), break (except for switch) or similar. It will result in grade of zero. No additional attempts would be allowed
Use const ( array size) and enums (menu choices, sort choice) were appropriate
The length of a file is unknown; make sure your programs handles empty files and files that have more records than an array can fit.
Follow established best practices and create cohesive functions. For example, a sort function should only sort. It should not ask a user what field to sort by and should not print.
Clearly label the output
Well document your code (comments)
Include your test data and our input file
Test your program thoroughly; at least 100 records.
Record must be in the following order: Firs Name, Last Name, GPA, ID, email
example: Mary Jones 3.9 887196478 may.jones@pierce.edu
#include
#include
#include
using namespace std;
class Records
{
public:
string FirstName, LastName, Email, ID;
double GPA;
void UnsortedPrint(Records StudentRc[],int x)
const;
void IDsearchRecord(Records StudentRc[],int x)
const;
};
void Records::UnsortedPrint(Records StudentRc[],int x)
const
{
cout <<
"\n\t\tFirstName\tLastName\tGPA\tID\t\tEmail" << endl;
for (int i = 0; i < x; i++)
{
cout << "\t\t" <<
StudentRc[i].FirstName << "\t" << StudentRc[i].LastName
<< "\t"
<<
StudentRc[i].GPA << "\t" << StudentRc[i].ID <<
"\t\t" << StudentRc[i].Email << endl;
}
}
void Records::IDsearchRecord(Records StudentRc[],int x)
const
{
string Num;
bool found = false;
cout << "\n\tEnter studnet ID : ";
cin >> Num;
for (int i = 0; i < x; i++)
{
if (StudentRc[i].ID == Num)
{
cout <<
"\tRecord Number\t\tFirstName\tLastName\tGPA\tID\t\tEmail" <<
endl;
cout <<
"\t\t" << StudentRc[i].FirstName << "\t" <<
StudentRc[i].LastName << "\t"
<< StudentRc[i].GPA << "\t" <<
StudentRc[i].ID << "\t\t" << StudentRc[i].Email
<< endl;
found =
true;
}
}
if (!found)
cout << "\n\t" << Num
<< " is not found in the data." << endl;
}
int main()
{
Records Studnet;
Records StudentRc[100];
fstream inFile;
char Option = 'x';
int x = 0;
inFile.open("C:\\Users\\JONGMIN\\Desktop\\540
C++\\inFile.txt");
while (!inFile.eof())
{
inFile >>
StudentRc[x].FirstName >> StudentRc[x].LastName;
inFile >> StudentRc[x].GPA
>> StudentRc[x].ID >> StudentRc[x].Email;
++x;
}
while (true) //Fixeit
{
cout << "\n\tA. Print records
that is unsorted " << endl;
cout << "\tB. Search student
records by student ID " << endl;
cout << "\tC. Quit the
program" << endl;
cout << "\tOption : ";
cin >> Option;
switch (Option)
{
case 'A':
case 'a':
Studnet.UnsortedPrint(StudentRc,x);
break;
case 'B':
case 'b':
Studnet.IDsearchRecord(StudentRc,x);
break;
case 'C':
case 'c':
exit(1);
break;
default:
cout <<
"\nYou entered a wrong option. Please enter the initial in the Menu
\n\n";
break;
}
}
inFile.close();
system("pause");
return 0;
}
Write a modularized, menu-driven program to read a file with unknown number of records.
Write a program that will maintain a personal phonebook. The program should be menu driven. Create a new phonebook Print the phonebook Add person to the phonebook Remove a person from the phonebook Sort Modify a person Search for a person by name Save to a data file (Can't be done but leave an error message if the user selects) Retreive phonebook from data file (Can't be done but leave an error message if the user selects) Quit Create a...
In C++
Write a menu driven C++ program to read a file containing
information for a list of Students, process the data, then present
a menu to the user, and at the end print a final report shown
below. You may(should) use the structures you developed for the
previous assignment to make it easier to complete this assignment,
but it is not required.
Required Menu Operations are:
Read Students’ data from a file to update the list (refer to
sample...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
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...
In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...
Visual C#
Homework 2
You are to write a program which will create a class called
Student
Each student has a name age height and weight. These variables
should be declared as private.
Create the correct constructors and functions.
In the main, you will create 5 students.
Input the data for the 5 students from a file which already
has information in it. Name the file “Information.txt”.
After setting up all the data, it is time to sort based on...
Write a JAVA Program: Compare the performance of bubble sort and selection sort over several arrays. - Write two methods that sort arrays of doubles. One method should use selection sort, and the other should use bubble sort. - In each of the sort methods, add code that counts the total number of comparisons and total number of swaps performed while sorting the entire array (be careful; don't count each pass through the array separately) - Each time an array...
Write a menu-driven program to read a list of students’ surnames and perform the following: a) Print the initial list of surnames b) Sort the surnames in ascending order and print the sorted list c) Sort the surnames in descending order and print the sorted list. using c programing and write its flow chat.through user input.
Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...
• Add a menu bar to the program with a File menu.
• In the File menu, add a submenu (JMenuItem) called About.
• When the user clicks on the About menu item, display a
JOptionPane message dialog that contains your name, your course,
the section number, and ID.
Add comments to the top of each source code file that includes
your name, course number, section number, and ID.
2. In Chapter 5, you created a lottery game application. Create...