Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
void removeStudent()
{
System.out.print("\n Enter StudentID to remove: ");
long id =sc.nextLong();
int pos = searchStudentID(id);
if(pos == -1)
System.out.println("\n ERROR: No student found having same ID: " + id);
else
courses.remove(pos);
}
int searchStudentID(long studentID)
{
for(int c = 0; c < students.size(); c++)
if(studentID == students.get(c).getId())
return c;
return -1;
}
The code is supposed to prompt the user to enter a studentID and if it is in the records then it will be removed, but instead it just prompts me to enter and when i enter the ID, it just exits and goes back to the menu. is there something wrong with my code?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- A counter variable is normally used in a program to keep track of the current count value.Create your own counter data type which is able to perform common counter operations such as increment (by one) the counter value and decrement (by one) the counter value. It is also able to set the counter to a specific value and to retrieve the counter value. The minimum value the counter can attain is zero, while the maximum value attained is stored in attribute maxValue. The class should have the following private members (attributes): (first picture) In the main program, test the workablity of your member functions by first setting an initial value to the counter. Display this value before proceeding. Then test other functions by randomly incrementing and decrementing the object’s value. Be sure to keep track of your actions. At the same time you should also make sure that your minimum value should not be less than zero. Once this is reached you will not be allowed to do further decrements.…arrow_forwardA good string is a string or a substring that starts with the character "g" and ends with the character "d". For a given string, write a program to find the number of "good substrings" of a given string. Note - A substring of a string is a contiguous subsequence of that string. The list of all non-empty substrings of the string "apple" would be "apple", "appl", "pple", "app", "ppl", "ple", "ap", "pp", "pl", "le", "a", "p", "p", "I", and "e" There will be multiple test cases running so the Input and Output should match exactly as provided. The base output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables. Input Format The first line contains the string S. Sample Input godk - denotes S Constraints 1 <= len|S| <= 100 Output Format The output contains a single integer denoting the number of good substrings of the given string. Sample Output 1 Explanation In the given string, only one substring "god" is good.…arrow_forwarda java assignment about 4 used defined exception using array loop based on real life scenario. (use only java)arrow_forward
- Write the program to find all the grades fora specified student, as shown in Figure .arrow_forwardFor any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a comma (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20,30, 1 #include 2 3 int main(void) { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; 4 6 7 8 scanf("%d", &keysList[0]); scanf ("%d", &keysList[1]); scanf("%d", &keysList[2]); scanf("%d", &keysList[3]); 10 11 12 13 scanf ("%d", &itemsList[0]); scanf ("%d", &itemsList[1]); scanf("%d", &itemsList[2]); scanf ("%d", &itemsList[3]); 14 15 16 17 18 19 /* Your code goes here */ 20 21 printf("\n"); 22 23 return 0; 24 }arrow_forward• Do not add statements that call print, input , or open , or add an import statement. • Do not use any break or continue statements. We are imposing this restriction (and we have not even taught you these statements) because they are very easy to abuse, resulting in terrible, hard to read code. • Do not modify or add to the import statements provided in the starter code. import math from typing import List, TextIO # For simplicity, we'll use "Station" in our type contracts to indicate that # we mean a list containing station data. # You can read "Station" in a type contract as: List[int, str, float, float, int, int, int] 23 # where the values at each index represent the station data as described in the # handout on Quercus. # A set of constants, each representing a list index for station information. ID - 0 NAME - 1 LATITUDE - 2 LONGITUDE - 3 CAPACITY - 4 BIKES_AVAILABLE - 5 DOCKS_AVAILABLE - 6 NO_KIOSK - 'SMART" # For use in the get_lat_lon_distance helper function EARTH RADIUS -…arrow_forward
- Exercise 2.3. What is wrong with this procedure, which is supposed to return True if the element x occurs in the list items, and False otherwise? def member (x, items): for i in items: if x == 1: return True else: return Falsearrow_forward____ the number of arrangements of n objects in a given order of the objects r at a time.arrow_forwardWhen the following program is executed, it terminates with an error. Which option best describes the cause of this error? Question options: The function will terminate the program due to the recursive limit being reached. The function will terminate the program due to a type mismatch when evaluating an operator. The function will terminate the program due to invalid syntax. The function will terminate the program due to an invalid type conversion. The function will terminate the program due to it accessing an invalid list index. None of these optionsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education