I would love it if someone would make this code from scratch.. not copied from somewhere else. I just want this explained and how it is done. The extra credit would be nice too..
This is C++
//For any queries, feel free to comment.
// The following code is with the sorting algorithm for extra credit.
// The following code uses QuickSort to sort the array. If you want more details on sorting, comment below.
**CODE**
#include <bits/stdc++.h>
using namespace std;
int partition (string arr[], int low, int high)
{
int i = low - 1;
//Pivot = element whose correct
//position we want to find
string pivot = arr[high];
//Find correct position by looping
for (int j = low; j <= high - 1; j++)
{
// If current element is
smaller than the pivot
if (arr[j] <
pivot)
{
i++;
swap(arr[i], arr[j]);
}
}
swap(arr[i + 1], arr[high]);
return (i + 1);
}
//Main quickSort function
void quickSort(string arr[], int low, int high)
{
if (low < high)
{
//Find correct position
of one element at a time.
int pi = partition(arr,
low, high);
//Leaving pi and sort
remaining arrays by
//dividing it into two
parts
quickSort(arr, low, pi -
1);
quickSort(arr, pi + 1,
high);
}
}
int main()
{
int n;
cout<<"Enter number of students: ";
cin>>n;
string arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
quickSort(arr,0,n-1);
cout<<"First position:
"<<arr[0]<<"\n";
cout<<"Last position:
"<<arr[n-1]<<"\n";
return 0;
}
**SNIPPET**
**OUTPUT**
I would love it if someone would make this code from scratch.. not copied from somewhere...
Starting Out with c++ Student Line Up Using Files A teacher has asked all her students to line up according to their first name. For example, in one class Amy will be at the front of the line, and Yolanda will be at the end. Write a program that will prompt the user for a filename that contains the student names. Names should be read in until there is no more data to read. As the names are read in,...
Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...
I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student { private String name; private double gpa; private int idNumber; public Student() { this.name = ""; this.gpa = 0; this.idNumber = 0; } public Student(String name, double gpa, int idNumber) { this.name = name; this.gpa = gpa; this.idNumber = idNumber; } public Student(Student s)...
[JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...
ASSIGNMENT: Create a program to do the following: BONUS: A bonus of 20 points if you create the program in such a way that there is no limit on the number of names to be handled. 1) Read in names to sort until the user types the “enter” key as the first character of a “C-type” string (the maximum number of names is 20, there is not a maximum length to a name), using a two dimensional array of characters....
You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...
You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...
Write a program that performs the following: 1. Presents the user a menu where they choose between: a. Add a new student to the class i. Prompts for first name, last name ii. If assignments already exist, ask user for new student’s scores to assignments b. Assign grades for a new assignment i. If students already exist, prompt user with student name, ask them for score ii. Students created after assignment will need to...
How would you make it hold both the student's name and their teacher? then be able to sort based on either the students name or who their teacher is? import java.util.Scanner; //for taking user input public class StudentName{ //you can change class name public static void main(String[] args); { Scanner in = new Scanner(System.in); //finding length of array studentNames System.out.print("how many students? :") ; int totalStudents = in. nextInt() ; String[] studentNames = new String[totalStudents] ; //input user name for(int...
In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...