Population
Make sure you have downloaded the hook’s source code from the companion Web site at www.pearson.com/gaddis. In this chapter’s source code folder you will find a
DB or Apache Derby database named CityDB. The CityDB database will have a table named City, with the following columns:
Column Name | Data Type |
CityName | CHAR (50) |
Primary key | |
Population | DOUBLE |
The CityName column stores the name of a city and the Population column stores the population of that city. After you run the CreateCityDB.java program, the City table will contain 20 rows with various cities and their populations.
Next, write a program that connects to the CityDB database, and allows the user to select any of the following operations:
- Sort the list of cities by population, in ascending order.
- Sort the list of cities by population, in descending order.
- Sort the list of cities by name.
- Get the total population of all the cities.
- Get the average population of all the cities.
- Get the highest population.
- Get the lowest population.
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Absolute Java (6th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
C Programming Language
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Database Concepts (8th Edition)
- In java create an application to manage your data base information the database is already created in mysql tables, the tables are fill, So the user can use your database application user friendly Retrieve all data: Given a table name, retrieve all data from the table and present it to the user. Average: Given a table name and a column name, return the average of the column. Here the assumption is that the column type will be numeric (e.g., cost column). Insert: Given a table name, your program should show the column names of that table and ask the users to input new data to the table. In case of errors, your program should directly show the MySQL errors to the users. Assumption 1: Users will enter data according to the database constraints. Assumption 2: Users will input one record at a time. Delete: Given a table name, your program should show the column names of that table and ask the users to input data that they want to delete. Assumption 1: Users will enter data according to the…arrow_forwardIn derby database and java languagearrow_forwardassume that a database has a table named Stock, with thefollowing columns:Column Name TypeTrading_Symbol nchar(10)Company_Name nchar(25)Num_Shares intPurchase_Price moneySelling_Price money Write a Select statement that returns all the columns from the rows where Trading_Symbol starts with "SU".arrow_forward
- Code SQLarrow_forwardexample inn 100 sqlmstatementarrow_forwardassume that a database has a table named Stock, with thefollowing columns:Column Name TypeTrading_Symbol nchar(10)Company_Name nchar(25)Num_Shares intPurchase_Price moneySelling_Price money Write a Select statement that returns all the columns from every row in the table.arrow_forward
- SQL Database helparrow_forwardassume that a database has a table named Stock, with thefollowing columns:Column Name TypeTrading_Symbol nchar(10)Company_Name nchar(25)Num_Shares intPurchase_Price moneySelling_Price money Write a Select statement that returns the Trading_Symbol column only from the rows where Selling_Price is greater than Purchase_Price and Num_Shares is greater than 100.arrow_forwardTHIS MODULE IS ABOUT SUBQUERIES, SO YOU MUST USE SUBQUERIES INSTEAD OF TABLE JOINS IN THISASSIGNMENT.arrow_forward
- Relation: Relation is a two-dimensional table in which data is named. The relations have the named columns and numbers which denote the unnamed rows. Although relation is defined as the two-dimensional table of data, not all the tables are considered as relations. There are some properties that differentiate relation tables from non-relation tables.arrow_forwardclass Database:def __init__(self, db_name):self.db = sqlite3.connect(db_name)self.cursor = self.db.cursor()def create_table(self, table_schema):self.cursor.execute(table_schema)self.db.commit()def insert_data(self, table_name, data):for i in range(len(data)):keys = ", ".join(data.columns)values = ", ".join([f"'{value}'" if pd.isna(value) else str(value) for value in data.iloc[i]])self.cursor.execute(f"INSERT INTO {table_name} ({keys}) VALUES ({values})")self.db.commit()def search_data(self, table_name, year):self.cursor.execute(f"SELECT * FROM {table_name} WHERE year={year}")result = self.cursor.fetchone()if result is not None:return resultelse:return Nonedef delete_data(self, table_name, year):self.cursor.execute(f"DELETE FROM {table_name} WHERE year={year}")self.db.commit()return self.cursor.rowcount > 0 Please rewrite (or convert) the code above with format: def QueryBuilder( Data_Base, Query_Type, Query_Tuple):'''''' Build Query_String'''''' return Query_Stringarrow_forwardin C# Visual Studios Windows Form App (.Net Framework) Population Database In the Chap12 folder of the Student Sample Programs, you will find a database file named PopulationDB.mdf. The database has a table named City. The City table has the following columns: (see image) The City column stores the name of a city and the Population column stores the population of that city. The database has 20 rows already entered. Create an application that connects to the PopulationDB.mdf database and allows the user to perform the following: Use data-bound controls to add new rows to the database, change existing rows, and delete rows. Sort the list of cities by population, in ascending order. Sort the list of cities by population, in descending order. Sort the list of cities by name. Get the total population of all the cities. Get the average population of all the cities. Get the highest population. Get the lowest population.arrow_forward
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr