This program will function exactly the same as Ponder 02. It prompt the user for a filename. We will then read the contents of the file into a list. The program will then prompt the user for a name. Finally, we will tell the user whether the name is in the list.
Read From a File
The first part of the program will be to read the contents of a file into a list. This data will be in JSON. For example, the contents of the file languages.json might be:
{
"array": [
"C",
"C#",
"C++",
"Java",
"JavaScript",
"Kotlin",
"PHP",
"Perl",
"Python",
"Swift",
"VB"
]
}
Note that the contents of this file are guaranteed to be in sorted order. Of course, if the file does not exist, then a user-friendly message will be displayed to the user.
Advanced Search
Next the program will use the advanced search to determine if the name is in the list. This should behave exactly the same as it did for the linear search in Ponder 02. The only difference is that we will use a much more efficient algorithm to perform the search.
When finished, the program will display a message indicating whether the name was found.
Example
The following example is a single run-through of the program.
What is the name of the file? languages.json What name are we looking for? C++ We found C++ in languages.json.
In: Computer Science
Write a program that gathers input from the user and writes the
information out to a file (output.txt).
Your main method should gather the input, calculate the average,
and write the output. You should have a separate method that writes
the output to a file. You can have other methods as well if you
choose. However, you MUST have at least one other method in
addition to the main method.
Inputs:
Student Number
Name
Class name
Grades 1-5 (5 individual grades)
Output: Student Number: [student number]
Student Name: [student name]
Class: [class name]
Grade 1: [grade 1]
Grade 2: [grade 2]
Grade 3: [grade 3]
Grade 4: [grade 4]
Grade 5: [grade 5]
Average: [grade average]
Example output.txt file:
Student Number: 12345
Student Name: Marty McFly
Class: Music Theory
Grade 1: 90
Grade 2: 85
Grade 3: 70
Grade 4: 99
Grade 5: 96
Average: 88
In: Computer Science
Please Code Using Java
Create a class called SoccerPlayer
Create 4 private attributes: First Name, Last Name, Games, and Goals
Have two constructors
Constructor 1 – default constructor; all values to "NONE" or zero
Constructor 2 – accepts input of first name, last name, games and goals.
Create get and set methods for each of the four attributes
Create a method the returns a double that calculates the average goals per game
This method checks for zero games played:
If there are zero played, display an error and set average to 0;
If greater than zero, do the math and set average to result of calculation
Create a test program that allows you to set the first name, last name, number of games and number of goals. Call it SoccerPlayerTest.
Create two instances of players.
The first should use the default constructor and the set methods to fill the attributes
The second should use the other constructor to set the attributes
Display the info about the players including the average goals per game.
In: Computer Science
A typical American family uses 1000 kWh of electricity pro 30 days.
What is the average RMS current in the 160 V power line to the house?
In: Physics
Which of the following theories is used in the court's analysis provided in Wickard v. Filburn?
|
Cumulative Effect |
||
|
Substantial Economic Effect Theory |
||
|
Prohibitive Effect Theory |
In: Finance
Find the largest volume V = xyz of a box for which the point (x, y, z) is on the ellipsoid x^2 + 4y^2 + 16z^2 = 48
In: Math
1. How do chickens create such a large variety of lambda type light chains from a single functional V gene segment? Diagram and explain.
In: Biology
Select best choice and breifly explain your answer.
1. Smallest Radius? Sc Ti V
2. Greatest Volume S2- Ar Ca2+
In: Chemistry
Show that a graph T is a tree if and only if for every two vertices x, y ∈ V (T), there exists exactly one path from x to y.
In: Advanced Math
How would you, as an administrator of the health care organization, address the implications arising from the court's decision in the Darling v Charleston community Hospital case
In: Nursing