create code for deletestudentbyID Number for choice ==
4
package courseecom616;
import java.util.Scanner;
import java.util.ArrayList;
public class CourseeCOM616 {
private String courseName;
private String[] studentsName = new
String[1];
private String
studentId;
private int numberOfStudents;
public CourseeCOM616(String courseName) {
this.courseName =
courseName;
}
public String[] getStudentsName() {
return
studentsName;
}
public int getNumberOfStudents() {
return
numberOfStudents;
}
public String getStudentId() {
return studentId;
}
public void setStudentID(int studentID)
{
this.studentId =
studentId;
}
public String getCourseName(){
return courseName;
}
public void addStudent(String student) {
if (numberOfStudents ==
studentsName.length) {
String[] a = new String[studentsName.length + 1];
for (int i = 0; i < numberOfStudents; i++) {
a[i] = studentsName[i];
}
studentsName = a;
}
studentsName[numberOfStudents] = student;
numberOfStudents++;
}
public String[] addStudentByIndex(String
student, int index) {
String[] a = new
String[studentsName.length + 1];
if (numberOfStudents ==
studentsName.length) {
for (int i = 0; i < a.length; i++) {
if (i < index) {
a[i] = studentsName[i];
} else if (i == index) {
a[i] = student;
} else {
a[i] = studentsName[i - 1];
}
}
}
numberOfStudents++;
return a;
}
public static void display(String[] students)
{
System.out.println("========================");
System.out.print("Now
the New students Array is : \n");
for (int i = 0; i <
students.length; i++) {
System.out.println("Index: " + (i) + "--> " + students[i] + "
");
}
}
public void dropStudent(String student) {
int index = findStudent(student);
if (index >= 0) {
dropStudent(index);
}
else {
System.out.println(student + " is not in
the course: " + courseName);
}
}
private void dropStudent(int index)
{
String[] s = new
String[studentsName.length - 1];
for (int i = 0, j = 0; i < s.length;
i++, j++) {
if (i == index) {
j++;
}
s[i] = studentsName[j];
}
this.studentsName = s;
numberOfStudents--;
}
public String[] removeStudentByIndex(String[] a,
int index) {
String[] b = new
String[a.length - 1];
studentsName = a;
for (int i = 0, k = 0; i
< a.length; i++) {
if (i == index) {
continue;
} else {
b[k++] = a[i];
}
}
numberOfStudents--;
return b;
}
public String[] deleteStudentByID(String[] a,
int id) {
public String [] deleteStudentByName (String
students1 [], String name) {
String[] b = new
String[students1.length - 1];
for (int i = 0, k = 0; i
< students1.length; i++) {
if (students1[i].equals(name)) {
continue;
} else {
b[k++] = students1[i];
}
}
numberOfStudents--;
return b;
}
{
this.studentId =
studentId;
this.studentsName =
studentsName;
}
private int findStudent(String student) {
for (int i = 0; i <
numberOfStudents; i++) {
if (studentsName[i].equals(student)) {
return i;
}
}
return -1;
}
}
package courseecom616;
import java.util.Scanner;
import java.util.ArrayList;
public class d {
ArrayList <Students> students = new
ArrayList<> ();
public static void
main(String[] args) {
CourseeCOM616 com616 =
new CourseeCOM616("com616");
Com616.addStudent("Danny");
com616.addStudent("Harvey");
com616.addStudent("Joseph");
com616.addStudent("Ben");
com616.addStudent("Frank");
int sum = 0;
String students1[] =
com616.getStudentsName();
sum +=
com616.getNumberOfStudents();
students1 =
com616.getStudentsName();
Scanner scan = new
Scanner(System.in);
System.out.println("Welcome to College");
int choice;
do {
System.out.println("1) View Student");
System.out.println("2) Insert Student");
System.out.println("3) Remove a student");
System.out.println("4) Delete a student by ID");
System.out.println("5) Delete a student by name");
System.out.println("6) Exit");
choice = scan.nextInt();
if (choice == 1) {
for (int i = 0; i < students1.length; i++) {
System.out.println("Index number is: " + (i) + "---> " +
students1[i]);
students1 = com210.getStudentsName();
}
System.out.println("Number of students attending the Course is: " +
sum);
} else if (choice == 2) {
System.out.println("Enter the name of student and index: ");
scan.nextLine();
String student = scan.nextLine();
int index = scan.nextInt();
students1 = com616.addStudentByIndex(student, 3);
com616.display(students1);
sum = com616.getNumberOfStudents();
System.out.println("\nThe students in the course " +
com616.getCourseName() + ":" + sum);
System.out.println("------------------------------------------");
System.out.println();
} else if (choice == 3) {
System.out.println("Remove a student by index");
int index = scan.nextInt();
students1 = com616.removeStudentByIndex(students1, index);
sum = com616.getNumberOfStudents();
System.out.println("After student drop number is: " +
sum);
System.out.println("------------------------------------");
} else if (choice == 4) {
System.out.println("Delete a students name by their ID");
System.out.println("Enter students ID: ");
String name = scan.nextLine();
String Id = scan.nextLine();
} else if (choice == 5) {
System.out.println("Delete student by name");
System.out.println("Enter student name");
String name = scan.next();
students1 = com616.deleteStudentByName(students1, name);
com616.display(students1);
sum = com616.getNumberOfStudents();
System.out.println("After the student is dropped the number will
be: " + sum);
}
}
while (choice != 6);
System.out.println("This Program has ended");
}
}
In: Computer Science
Running laps: This is C++ Programming Coding Language
Everyone likes running laps in gym class right?
There are 5 objectives and 20 points each. Please indicate in code (or comments) where each objective begins and ends. It may be prudent to place each objective in it's own function.
In this lab you will be reading in a file of student results. The students each ran 3 laps in a race and their times to complete each lap are posted in the order that they completed the lap (the students will not necessarily be in the same order each lap). You will be outputting a number of results based on the student performance. And it should go without saying that you cannot hard-code any of the values into your program as the values I’ve given as an example are not the same values I will use to test it with. There is a maximum of 20 students that may participate in the race (though the example file only has 7).
Hint: times in the files are given as minutes:seconds. But many times, you need to add or do calculations with them together. So you will need to convert them to total seconds to do these calculations. Then for displaying you will need a function for converting them back.
Objective 1: Output the final times of all the students. I also want to know who placed 1st, 2nd and 3rd overall. (Though if you have them all in order that will be sufficient). You can order values simply by setting aside 3 variables and when you calculate a new score you see if it is the best, if so move the old best into 2nd place and move the 2nd place into 3rd place. If it isn’t the best, then move down to 2nd and try that one and so on.
I should also note that you may read a file as many times as you want. Though it is not necessarily the most efficient solution you may read the file over again for each student that participated.
Objective 2: I want the averages for each lap by all the students. Then output which students are above the average and which are below:
Lap 1 average: 2:05
Below: Akano, Wes, Kye, Edward (note that Edward is right on the
border and could be put in either)
Above: Jess, Ally, Wilt
Objective 3: Naturally, the students slowed down from lap to lap as they were running. I want the lap times and the difference between them posted for each student:
Lap 1
2 3
Akano 1:48 2:28 2:25
+40 -3 (note that she is one of the few
that needs a negative)
Objective 4: Consistency in races is important. I want to know the total range of each students fastest and slowest lap. In the end I want to know the top 3 most consistent runners:
Slowest
fastest difference
Akano:
2:28
1:48 40 sec
Objective 5: Now you are going to use both the example files together. The second results file contains the same students (though my test data will be 2 files with different number and names than the files you are given). I want a comparison of the student’s overall times from each results file:
1
2 difference
Akano: 6:41 5:49
-52 sec
Lap 1: Akano 1:48 Edward 1:50 Wes 1:55 Kye 1:59 Ally 2:04 Jess 2:18 Wilt 2:44 RESULTS TXT 1 Lap 2: Edward 1:56 Kye 2:21 Jess 2:21 Akano 2:28 Ally 2:33 Wes 2:43 Wilt 3:14 Lab 3: Kye 2:11 Akano 2:25 Wilt 3:01 Ally 3:10 Jess 3:11 Wes 3:18 Edward 3:34
Lap 1: Akano 1:43 Wes 1:45 Kye 1:52 Edward 2:05 Jess 2:14 Ally 2:26 Wilt 2:30 RESULTS TXT 2 Lap 2: Edward 1:50 Akano 2:00 Wes 2:03 Kye 2:15 Jess 2:16 Ally 2:23 Wilt 2:54 Lab 3: Kye 2:01 Akano 2:06 Ally 2:54 Wes 3:03 Wilt 3:11 Jess 3:15 Edward 3:21
In: Computer Science
In C++
Make changes to List.h and List.cpp, but not City.h or City.cpp.
Project includes Cities01.txt , City.h ,City.cpp , List.h , List.cpp , and Trial.cpp
Cities01.txt
Lansing 42.73 -84.55
Detroit 42.33 -83.04
Flint 43.01 -83.68
Grand-Rapids 42.96 -85.66
Jackson 42.27 -84.47
Kalamazoo 42.23 -85.55
Ann-Arbor 42.22 -83.75
Mt-Pleasant 43.60 -84.78
Clare 43.82 -84.77
Saginaw 43.42 -83.95
City.h
// City class definition
class city
{ friend class list;
public:
city(); // Constructor
bool get(istream& in); // Input name & location
void put(ostream& out); // Output data
private:
string name; // Name
float latitude,longitude; // Location
};
List.h
#define LIST_SIZE 20
#include "City.h"
class list
{ public:
list(); // Constructor - empty list
bool insert(city arg); // Add a city
void display(ostream& out); // Output data
void sort(string arg); // Sort by distance from arg
int size(); // Return number of cities
private:
int len; // Number of used cities
city map[LIST_SIZE]; // Data set
};
City.cpp
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#include "City.h"
/**************************************
* Constructor - no parameters
**************************************/
city::city()
{ name = "";
latitude = longitude = 0.0F;
}
/**************************************
* Get
**************************************/
bool city::get(istream &in)
{ in >> name;
in >> latitude;
in >> longitude;
return in.good();
}
/**************************************
* Put
**************************************/
void city::put(ostream &out)
{ out << left;
out << setw(14) << name;
out << right << fixed << setprecision(2);
out << setw(8) << latitude;
out << setw(8) << longitude;
}
List.cpp
#include <iostream>
#include <iomanip>
using namespace std;
#include "List.h"
/*************************************
* list()
*************************************/
list::list()
{ len = 0;
}
/*************************************
* insert()
*************************************/
bool list::insert(city arg)
{
// Check to see if there is room
if(len>=LIST_SIZE) return false;
// Add to array
map[len++] = arg;
// Return success
return true;
}
/*************************************
* display()
*************************************/
void list::display(ostream &out)
{
}
/*************************************
* size()
************************************/
int list::size()
{ return len;
}
Trial.cpp
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include "List.h"
/*************************************
* main()
*************************************/
void main()
{ string name;
fstream infile;
city c;
list state;
// Load from file
cout << "Enter file name: ";
cin >> name;
cout << endl;
infile.open(name,ios::in);
if(!infile.is_open()) return;
while(c.get(infile)) state.insert(c);
infile.close();
// Display
cout << state.size() << " Cities" << endl
<< endl;
state.display(cout);
/* Steps 10.6-7
// Sort by closest to here and display
cout << "Enter home city: ";
cin >> name;
cout << endl;
state.sort(name);
state.display(cout);
*/
}
Could use some help with implementing the list::display() function so the output looks like this:
Enter file name: Cities01.txt
10 Cities
City Lat Long
-------------- ------ ------
Lansing 42.73 -84.55
Detroit 42.33 -83.04
Flint 43.01 -83.68
Grand-Rapids 42.96 -85.66
Jackson 42.27 -84.47
Kalamazoo 42.23 -85.55
Ann-Arbor 42.22 -83.75
Mt-Pleasant 43.60 -84.78
Clare 43.82 -84.77
Saginaw 43.42 -83.95
Create a private function list::dist() that takes two integers src and dst, and calculates the distance between the cities at index src and dst. Hint:
Distance = Sqrt((latsrc-latdist)^2+(longsrc-longdist)^2)
Update the display() function so it calls the distance() function to display the distance between each city and the first city in the list. Uncomment the section in main() for steps 10.6-7. Implement the list::sort() function in two parts:
Output should look like this:
Enter file name: Cities01.txt
10 Cities
City Lat Long Dist
-------------- ------ ------ ------
Lansing 42.73 -84.55 0.00
Detroit 42.33 -83.04 1.56
Flint 43.01 -83.68 0.91
Grand-Rapids 42.96 -85.66 1.13
Jackson 42.27 -84.47 0.47
Kalamazoo 42.23 -85.55 1.12
Ann-Arbor 42.22 -83.75 0.95
Mt-Pleasant 43.60 -84.78 0.90
Clare 43.82 -84.77 1.11
Saginaw 43.42 -83.95 0.91
Enter home city: Lansing
City Lat Long Dist
-------------- ------ ------ ------
Lansing 42.73 -84.55 0.00
Jackson 42.27 -84.47 0.47
Mt-Pleasant 43.60 -84.78 0.90
Flint 43.01 -83.68 0.91
Saginaw 43.42 -83.95 0.91
Ann-Arbor 42.22 -83.75 0.95
Clare 43.82 -84.77 1.11
Kalamazoo 42.23 -85.55 1.12
Grand-Rapids 42.96 -85.66 1.13
Detroit 42.33 -83.04 1.56
In: Computer Science
Suppose a system uses a Public-Key Infrastructure with a Certificate Revocation List. A device in that system is asked to verify a certificate but cannot access the Certificate Revocation List database because of a denial of service attack What are the possible courses of action for the device, and what are the advantages and disadvantages of each course of action?
In: Computer Science
In: Biology
1. How is poultry classified?
2. What are the USDA grades for poultry?
3. List safety concerns and safe food handling techniques for preparing and storing chicken.
4. What are some low fat preparation techniques used for chicken?
5. List the forms of chicken that can be purchased.
In: Nursing
1) In general, is the hindlimb of Australopithecus more human-like, ape-like or in-between? List two examples (traits) to support your answer.
2) In general, is the cranium of Australopithecus afarensis more human-like, ape-like or in-between? List two examples (traits) to support your answer.
In: Biology
After the introduction of a new information system, a post implementation review is usually carried out.
1. List and describe three reasons for this review?
2. Describe three assessment/evaluation criteria that may be used in this review?
3. List and describe three factors that the post implementation review considers?
In: Accounting
Write a function parent_index_3_heap(child_index) that returns the index of the parent of the node at the given child_index. A None value should be returned if the child has no parent.
Notes:
This is for Python
In: Computer Science
Please solve the following problem for MATLAB
Write a user-defined function that calculates the average and the standard deviation of a list of numbers. Use the function to calculate the average and the standard deviation of the following list of grades : 80 75 91 60 79 89 65 80 95 50 81
In: Computer Science