DATA STRUCTURE C++ LANGUGAE
Create a notepad that allows the user to write text (char by
char) on the console. For this
purpose, the user should be able to control and track the movement
of the cursor. The user
should be able to navigate to any part of console (cursor control)
in order to perform any
insertion or deletion of words.
Internally, the notepad is composed of two-dimensional linked list
(every node should
comprise of data element (char) and 4 pointers for navigating left,
right, up, and down). Since
text can be written on multiple lines, each row of the 2D linked
list represents one line. Each
line is terminated when a newline is inserted in the ADT.
In: Computer Science
Systems Analysis and Design
Create a Context Diagram for a purchasing system.
Create this first level of a DFD for this system.
Help is much appreciated. Thank you..
In: Computer Science
Write a method with the following header to return an
array of integer values which are the largest values from each row
of a 2D array of integer values
public static int[] largestValues(int[][] num)
For example, if the 2D array passed to the method is:
8 5 5 6 6
3 6 5 4 5
2 5 4 5 2
8 8 5 1 6
The method returns an array of integers which are the largest
values from each row as follows:
8
6
5
8
In the main method, create a 2D array of integer values with the
array size 4 by 5 and invoke the method to find and display the
largest values from each row of the 2D array.
You can generate the values of the 2D array using the Math.random()
method with the range from 0 to 9.
In: Computer Science
JAVA programming
A zoo is developing an educational safari game with various animals. You will write classes representing Elephants, Camels, and Moose.
Part A: Think through common characteristics of animals, and write a class ZooAnimal.
☑ ZooAnimal should have at least two instance variables of different types (protected), representing characteristics that all animals have values for.
☑ It should also have at least two methods for behaviors that all animals do; these can simply print out a String stating what the animal is doing. (accessors and mutators are not behaviors). Include at least one parameterized constructor.
Part B ☑ Create classes Elephant, Camel, and Moose, all of which extend ZooAnimal. In each, include a default constructor that calls the parameterized superclass constructor.
☑ To one class (of Elephant, Camel, and Moose), add another instance variable specific to that type of animal. To another, add another behavior method. In a third, override a behavior from ZooAnimal.
Part C ☑ Create a test harness for the animal classes. In a main create at least one Elephant, Camel, and Moose, and show which behavior methods are usable for each.
☑ [EC+10] Create another animal class inheriting from one of your three types (doesn't have to be zoologically accurate, but should make some sense), and either add an instance variable or add or override a method. This class should also be tested in the harness.
In: Computer Science
What is a geographic information system (GIS)? What purpose does it server? Name the two major elements that are combined to make up a GIS.
In: Computer Science
Download the world.SQL and run it in MySQL. Now based on this database, write query that shows a) the most populated city in each country. b) the second most populated city in each country. c) the most populated city in each continent. d) the most populated country in each continent. e) the most populated continent. f) the number of people speaking each language. g) the most spoken language in each continent. h) number of languages that they are official language of at least one country. i) the most spoken official language based on each continent. (the language that has the highest number of people talking as their mother tongue) j) the country with the most (number of) unofficial languages based on each continent. (no matter how many people talking that language) k) the countries that their capital is not the most populated city in the country. l) the countries with population smaller than Russia but bigger than Denmark.
script is below---
DROP SCHEMA IF EXISTS world;
CREATE SCHEMA world;
USE world;
SET AUTOCOMMIT=0;
--
-- Table structure for table `city`
--
DROP TABLE IF EXISTS `city`;
CREATE TABLE `city` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`Name` CHAR(35) NOT NULL DEFAULT '',
`CountryCode` CHAR(3) NOT NULL DEFAULT '',
`District` CHAR(20) NOT NULL DEFAULT '',
`Population` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`));
--
-- Dumping data for table `city`
--
-- ORDER BY: `ID`
INSERT INTO `city` VALUES
(1,'Kabul','AFG','Kabol',1780000);
INSERT INTO `city` VALUES
(2,'Qandahar','AFG','Qandahar',237500);
INSERT INTO `city` VALUES (3,'Herat','AFG','Herat',186800);
INSERT INTO `city` VALUES
(4,'Mazar-e-Sharif','AFG','Balkh',127800);
INSERT INTO `city` VALUES
(5,'Amsterdam','NLD','Noord-Holland',731200);
INSERT INTO `city` VALUES
(6,'Rotterdam','NLD','Zuid-Holland',593321);
INSERT INTO `city` VALUES
(7,'Haag','NLD','Zuid-Holland',440900);
INSERT INTO `city` VALUES
(8,'Utrecht','NLD','Utrecht',234323);
INSERT INTO `city` VALUES
(9,'Eindhoven','NLD','Noord-Brabant',201843);
INSERT INTO `city` VALUES
(10,'Tilburg','NLD','Noord-Brabant',193238);
INSERT INTO `city` VALUES
(11,'Groningen','NLD','Groningen',172701);
INSERT INTO `city` VALUES
(12,'Breda','NLD','Noord-Brabant',160398);
INSERT INTO `city` VALUES
(13,'Apeldoorn','NLD','Gelderland',153491);
INSERT INTO `city` VALUES
(14,'Nijmegen','NLD','Gelderland',152463);
INSERT INTO `city` VALUES
(15,'Enschede','NLD','Overijssel',149544);
INSERT INTO `city` VALUES
(16,'Haarlem','NLD','Noord-Holland',148772);
INSERT INTO `city` VALUES
(17,'Almere','NLD','Flevoland',142465);
INSERT INTO `city` VALUES
(18,'Arnhem','NLD','Gelderland',138020);
INSERT INTO `city` VALUES
(19,'Zaanstad','NLD','Noord-Holland',135621);
INSERT INTO `city` VALUES
(20,'´s-Hertogenbosch','NLD','Noord-Brabant',129170);
INSERT INTO `city` VALUES
(21,'Amersfoort','NLD','Utrecht',126270);
INSERT INTO `city` VALUES
(22,'Maastricht','NLD','Limburg',122087);
INSERT INTO `city` VALUES
(23,'Dordrecht','NLD','Zuid-Holland',119811);
INSERT INTO `city` VALUES
(24,'Leiden','NLD','Zuid-Holland',117196);
INSERT INTO `city` VALUES
(25,'Haarlemmermeer','NLD','Noord-Holland',110722);
INSERT INTO `city` VALUES
(26,'Zoetermeer','NLD','Zuid-Holland',110214);
INSERT INTO `city` VALUES
(27,'Emmen','NLD','Drenthe',105853);
INSERT INTO `city` VALUES
(28,'Zwolle','NLD','Overijssel',105819);
INSERT INTO `city` VALUES
(29,'Ede','NLD','Gelderland',101574);
INSERT INTO `city` VALUES
(30,'Delft','NLD','Zuid-Holland',95268);
INSERT INTO `city` VALUES
(31,'Heerlen','NLD','Limburg',95052);
INSERT INTO `city` VALUES
(32,'Alkmaar','NLD','Noord-Holland',92713);
INSERT INTO `city` VALUES
(33,'Willemstad','ANT','Curaçao',2345);
INSERT INTO `city` VALUES
(34,'Tirana','ALB','Tirana',270000);
INSERT INTO `city` VALUES (35,'Alger','DZA','Alger',2168000);
INSERT INTO `city` VALUES (36,'Oran','DZA','Oran',609823);
INSERT INTO `city` VALUES
(37,'Constantine','DZA','Constantine',443727);
INSERT INTO `city` VALUES
(38,'Annaba','DZA','Annaba',222518);
INSERT INTO `city` VALUES (39,'Batna','DZA','Batna',183377);
INSERT INTO `city` VALUES (40,'Sétif','DZA','Sétif',179055);
INSERT INTO `city` VALUES (41,'Sidi Bel Abbès','DZA','Sidi Bel
Abbès',153106);
INSERT INTO `city` VALUES
(42,'Skikda','DZA','Skikda',128747);
INSERT INTO `city` VALUES
(43,'Biskra','DZA','Biskra',128281);
INSERT INTO `city` VALUES (44,'Blida
(el-Boulaida)','DZA','Blida',127284);
INSERT INTO `city` VALUES
(45,'Béjaïa','DZA','Béjaïa',117162);
INSERT INTO `city` VALUES
(46,'Mostaganem','DZA','Mostaganem',115212);
INSERT INTO `city` VALUES
(47,'Tébessa','DZA','Tébessa',112007);
INSERT INTO `city` VALUES (48,'Tlemcen
(Tilimsen)','DZA','Tlemcen',110242);
INSERT INTO `city` VALUES
(49,'Béchar','DZA','Béchar',107311);
INSERT INTO `city` VALUES
(50,'Tiaret','DZA','Tiaret',100118);
INSERT INTO `city` VALUES (51,'Ech-Chleff
(el-Asnam)','DZA','Chlef',96794);
INSERT INTO `city` VALUES
(52,'Ghardaïa','DZA','Ghardaïa',89415);
INSERT INTO `city` VALUES (53,'Tafuna','ASM','Tutuila',5200);
INSERT INTO `city` VALUES
(54,'Fagatogo','ASM','Tutuila',2323);
INSERT INTO `city` VALUES (55,'Andorra la Vella','AND','Andorra la
Vella',21189);
INSERT INTO `city` VALUES
(56,'Luanda','AGO','Luanda',2022000);
INSERT INTO `city` VALUES
(57,'Huambo','AGO','Huambo',163100);
INSERT INTO `city` VALUES
(58,'Lobito','AGO','Benguela',130000);
INSERT INTO `city` VALUES
(59,'Benguela','AGO','Benguela',128300);
INSERT INTO `city` VALUES
(60,'Namibe','AGO','Namibe',118200);
INSERT INTO `city` VALUES (61,'South Hill','AIA','',961);
INSERT INTO `city` VALUES (62,'The Valley','AIA','',595);
INSERT INTO `city` VALUES (63,'Saint John´s','ATG','St
John',24000);
INSERT INTO `city` VALUES (64,'Dubai','ARE','Dubai',669181);
INSERT INTO `city` VALUES (65,'Abu Dhabi','ARE','Abu
Dhabi',398695);
INSERT INTO `city` VALUES
(66,'Sharja','ARE','Sharja',320095);
INSERT INTO `city` VALUES (67,'al-Ayn','ARE','Abu
Dhabi',225970);
INSERT INTO `city` VALUES (68,'Ajman','ARE','Ajman',114395);
INSERT INTO `city` VALUES (69,'Buenos Aires','ARG','Distrito
Federal',2982146);
INSERT INTO `city` VALUES (70,'La Matanza','ARG','Buenos
Aires',1266461);
INSERT INTO `city` VALUES
(71,'Córdoba','ARG','Córdoba',1157507);
INSERT INTO `city` VALUES (72,'Rosario','ARG','Santa
Fé',907718);
INSERT INTO `city` VALUES (73,'Lomas de Zamora','ARG','Buenos
Aires',622013);
INSERT INTO `city` VALUES (74,'Quilmes','ARG','Buenos
Aires',559249);
INSERT INTO `city` VALUES (75,'Almirante Brown','ARG','Buenos
Aires',538918);
INSERT INTO `city` VALUES (76,'La Plata','ARG','Buenos
Aires',521936);
INSERT INTO `city` VALUES (77,'Mar del Plata','ARG','Buenos
Aires',512880);
INSERT INTO `city` VALUES (78,'San Miguel de
Tucumán','ARG','Tucumán',470809);
INSERT INTO `city` VALUES (79,'Lanús','ARG','Buenos
Aires',469735);
INSERT INTO `city` VALUES (80,'Merlo','ARG','Buenos
Aires',463846);
INSERT INTO `city` VALUES (81,'General San Martín','ARG','Buenos
Aires',422542);
INSERT INTO `city` VALUES (82,'Salta','ARG','Salta',367550);
INSERT INTO `city` VALUES (83,'Moreno','ARG','Buenos
Aires',356993);
INSERT INTO `city` VALUES (84,'Santa Fé','ARG','Santa
Fé',353063);
INSERT INTO `city` VALUES (85,'Avellaneda','ARG','Buenos
Aires',353046);
INSERT INTO `city` VALUES (86,'Tres de Febrero','ARG','Buenos
Aires',352311);
INSERT INTO `city` VALUES (87,'Morón','ARG','Buenos
Aires',349246);
INSERT INTO `city` VALUES (88,'Florencio Varela','ARG','Buenos
Aires',315432);
INSERT INTO `city` VALUES (89,'San Isidro','ARG','Buenos
Aires',306341);
INSERT INTO `city` VALUES (90,'Tigre','ARG','Buenos
Aires',296226);
INSERT INTO `city` VALUES (91,'Malvinas Argentinas','ARG','Buenos
Aires',290335);
INSERT INTO `city` VALUES (92,'Vicente López','ARG','Buenos
Aires',288341);
INSERT INTO `city` VALUES (93,'Berazategui','ARG','Buenos
Aires',276916);
INSERT INTO `city` VALUES
(94,'Corrientes','ARG','Corrientes',258103);
INSERT INTO `city` VALUES (95,'San Miguel','ARG','Buenos
Aires',248700);
INSERT INTO `city` VALUES (96,'Bahía Blanca','ARG','Buenos
Aires',239810);
INSERT INTO `city` VALUES (97,'Esteban Echeverría','ARG','Buenos
Aires',235760);
INSERT INTO `city` VALUES
(98,'Resistencia','ARG','Chaco',229212);
INSERT INTO `city` VALUES (99,'José C. Paz','ARG','Buenos
Aires',221754);
INSERT INTO `city` VALUES (100,'Paraná','ARG','Entre
Rios',207041);
INSERT INTO `city` VALUES (101,'Godoy
Cruz','ARG','Mendoza',206998);
INSERT INTO `city` VALUES
(102,'Posadas','ARG','Misiones',201273);
INSERT INTO `city` VALUES
(103,'Guaymallén','ARG','Mendoza',200595);
INSERT INTO `city` VALUES (104,'Santiago del
Estero','ARG','Santiago del Estero',189947);
INSERT INTO `city` VALUES (105,'San Salvador de
Jujuy','ARG','Jujuy',178748);
INSERT INTO `city` VALUES (106,'Hurlingham','ARG','Buenos
Aires',170028);
INSERT INTO `city` VALUES
(107,'Neuquén','ARG','Neuquén',167296);
INSERT INTO `city` VALUES (108,'Ituzaingó','ARG','Buenos
Aires',158197);
INSERT INTO `city` VALUES (109,'San Fernando','ARG','Buenos
Aires',153036);
INSERT INTO `city` VALUES
(110,'Formosa','ARG','Formosa',147636);
INSERT INTO `city` VALUES (111,'Las
Heras','ARG','Mendoza',145823);
INSERT INTO `city` VALUES (112,'La Rioja','ARG','La
Rioja',138117);
INSERT INTO `city` VALUES (113,'San Fernando del Valle de
Cata','ARG','Catamarca',134935);
INSERT INTO `city` VALUES (114,'Río
Cuarto','ARG','Córdoba',134355);
INSERT INTO `city` VALUES (115,'Comodoro
Rivadavia','ARG','Chubut',124104);
INSERT INTO `city` VALUES
(116,'Mendoza','ARG','Mendoza',123027);
INSERT INTO `city` VALUES (117,'San Nicolás de los
Arroyos','ARG','Buenos Aires',119302);
INSERT INTO `city` VALUES (118,'San Juan','ARG','San
Juan',119152);
INSERT INTO `city` VALUES (119,'Escobar','ARG','Buenos
Aires',116675);
INSERT INTO `city` VALUES (120,'Concordia','ARG','Entre
Rios',116485);
INSERT INTO `city` VALUES (121,'Pilar','ARG','Buenos
Aires',113428);
INSERT INTO `city` VALUES (122,'San Luis','ARG','San
Luis',110136);
INSERT INTO `city` VALUES (123,'Ezeiza','ARG','Buenos
Aires',99578);
INSERT INTO `city` VALUES (124,'San
Rafael','ARG','Mendoza',94651);
INSERT INTO `city` VALUES (125,'Tandil','ARG','Buenos
Aires',91101);
INSERT INTO `city` VALUES
(126,'Yerevan','ARM','Yerevan',1248700);
INSERT INTO `city` VALUES (127,'Gjumri','ARM','irak',211700);
INSERT INTO `city` VALUES
(128,'Vanadzor','ARM','Lori',172700);
INSERT INTO `city` VALUES (129,'Oranjestad','ABW','',29034);
INSERT INTO `city` VALUES (130,'Sydney','AUS','New South
Wales',3276207);
INSERT INTO `city` VALUES
(131,'Melbourne','AUS','Victoria',2865329);
INSERT INTO `city` VALUES
(132,'Brisbane','AUS','Queensland',1291117);
INSERT INTO `city` VALUES (133,'Perth','AUS','West
Australia',1096829);
INSERT INTO `city` VALUES (134,'Adelaide','AUS','South
Australia',978100);
INSERT INTO `city` VALUES (135,'Canberra','AUS','Capital
Region',322723);
INSERT INTO `city` VALUES (136,'Gold
Coast','AUS','Queensland',311932);
INSERT INTO `city` VALUES (137,'Newcastle','AUS','New South
Wales',270324);
INSERT INTO `city` VALUES (138,'Central Coast','AUS','New South
Wales',227657);
INSERT INTO `city` VALUES (139,'Wollongong','AUS','New South
Wales',219761);
INSERT INTO `city` VALUES
(140,'Hobart','AUS','Tasmania',126118);
INSERT INTO `city` VALUES
(141,'Geelong','AUS','Victoria',125382);
INSERT INTO `city` VALUES
(142,'Townsville','AUS','Queensland',109914);
INSERT INTO `city` VALUES
(143,'Cairns','AUS','Queensland',92273);
INSERT INTO `city` VALUES (144,'Baku','AZE','Baki',1787800);
INSERT INTO `city` VALUES (145,'Gäncä','AZE','Gäncä',299300);
INSERT INTO `city` VALUES
(146,'Sumqayit','AZE','Sumqayit',283000);
INSERT INTO `city` VALUES
(147,'Mingäçevir','AZE','Mingäçevir',93900);
INSERT INTO `city` VALUES (148,'Nassau','BHS','New
Providence',172000);
INSERT INTO `city` VALUES
(149,'al-Manama','BHR','al-Manama',148000);
INSERT INTO `city` VALUES
(150,'Dhaka','BGD','Dhaka',3612850);
INSERT INTO `city` VALUES
(151,'Chittagong','BGD','Chittagong',1392860);
INSERT INTO `city` VALUES
(152,'Khulna','BGD','Khulna',663340);
INSERT INTO `city` VALUES
(153,'Rajshahi','BGD','Rajshahi',294056);
INSERT INTO `city` VALUES
(154,'Narayanganj','BGD','Dhaka',202134);
INSERT INTO `city` VALUES
(155,'Rangpur','BGD','Rajshahi',191398);
INSERT INTO `city` VALUES
(156,'Mymensingh','BGD','Dhaka',188713);
INSERT INTO `city` VALUES
(157,'Barisal','BGD','Barisal',170232);
In: Computer Science
Describe how five career areas can benefit from computer systems..
In: Computer Science
Need the following program in Python:
Create a program that calculates the estimated duration of a trip in hours and minutes. This should include an estimated date/time of departure and an estimated date/time of arrival.
Arrival Time Estimator Enter date of departure (YYYY-MM-DD): 2016-11-23 Enter time of departure (HH:MM AM/PM): 10:30 AM Enter miles: 200 Enter miles per hour: 65 Estimated travel time Hours: 3 Minutes: 5 Estimated date of arrival: 2016-11-23 Estimated time of arrival: 01:35 PM Continue? (y/n): y Enter date of departure (YYYY-MM-DD): 2016-11-29 Enter time of departure (HH:MM AM/PM): 11:15 PM Enter miles: 500 Enter miles per hour: 80 Estimated travel time Hours: 6 Minutes: 20 Estimated date of arrival: 2016-11-30 Estimated time of arrival: 05:35 AM Continue? (y/n): n Bye! |
Specifications
In: Computer Science
In C++
Extra credit This is the formula for the future worth of an investment over time with consistent additional monthly payments and a steady rate of return. This can give you a bonus of 200 points. You will not be penalized if you do not do this nor will you be penalized if it is incorrect. This is a challenging problem because of all the mathematics involved. Let’s see how good you really are. FV = PV (1+ r/k) nk +PMT * [ (1+r/k) nk −1] * (1+ r/k) r/k FV : future value PV : initial value R : interest rate K : regular periodic investments • Annually, • Semi-annually, • Quarterly, • Monthly PMT: payment (installments) N : years Problem: You wish to start putting money away for your retirement (far-fetched, huh) anyway, how much would you have after 45 years if you started with an initial payment (PV) of $1000.00 and invested $250 (K) monthly. The dividend payments are 6% (R)and you invest $250 a month for the next 45 years. Your investment has an annual rate of return (R) of 6%.
Show how you would break this problem down into pieces (your pseudo code).
Then show your source code and display your initial investment, rate of return, length of time, monthly payments into the account and the final outcome. Show how much money you invested and what the final amount is, you’ll be surprised. HINT: try doing this problem manually first
In: Computer Science
In: Computer Science
What is the result of the following statement?
not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
It is python logical operator (not, and, or)
I know the result is 4 by running the code, but I don't understand the logic behind it, can you explain it step by step? e.g. How to eliminate those numbers in each step to get the result.
Thanks
In: Computer Science
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.)
void remove_list(struct linked_list* list) //*This is the function to make and below is the explanation that should be written in given code.
"This function removes the list. When the list is removed, all the memory should be released to operating system (OS) so that OS lets other computer programs use this. While deleting the list, every node should be freed separately; free(list) will not remove every node in the list. To check whether the nodes are removed perfectly, for every deletion of a node, this function should print message “The node with value n (corresponding value) is deleted!” Also, if the whole list is deleted, this function should print message “The list is completely deleted: n nodes are deleted”."
Given code is written below,(There is a function to fill in last moment in this code)
linked_list.h: This is the header file of linkLQS.c that declares all the functions and values that are going to be used in linkLQS.c. You do not have to touch this function.
-----------------------------------------------------------------------
(Below code is about linked_list.h)
#include
#include
#include
struct linked_node{
int value;
struct linked_node* next;
struct linked_node* prev;
};
struct linked_list{
int type_of_list; // normal = 0, stack = 1
struct linked_node* head;
struct linked_node* tail;
int number_of_nodes;
};
--------------------------------------------------------
#include "linked_list.h"
#include "string.h"
extern int list_exist;
struct linked_list* create_list (int number_of_nodes, int
list_type)
{
int a[number_of_nodes];
int i, j;
int bFound;
if (number_of_nodes < 1)
{
printf("Function create_list: the
number of nodes is not specified correctly\n");
return NULL;
}
if(list_exist == 1)
{
printf("Function create_list: a
list already exists\nRestart a Program\n");
exit(0);
}
if(list_type != 0 && list_type != 1)
{
printf("Function create_list: the
list type is wrong\n");
exit(0);
}
struct linked_list * new_list = (struct
linked_list*)malloc(sizeof(struct linked_list));
new_list->head = NULL;
new_list->tail = NULL;
new_list->number_of_nodes = 0;
new_list->type_of_list = list_type;
//now put nodes into the list with random
numbers.
srand((unsigned int)time(NULL));
if(list_type == 0)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
insert_node(new_list, new_node);
}
}
else if(list_type == 1)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
push_Stack(new_list, new_node);
}
}
list_exist = 1;
printf("List is created!\n");
return new_list;
}
struct linked_node* create_node (int node_value)//This
functon is the example for reference of the assignment
function
{
struct linked_node* node = (struct
linked_node*)malloc(sizeof(struct linked_node));
node->value = node_value;
node->next = NULL;
node->prev = NULL;
return node;
}
void insert_node(struct linked_list* list, struct
linked_node* node)//This functon is the example for reference of
the assignment function
{
node->next = NULL;
node->prev = NULL;
if(list->head == NULL)
//if head is NULL, tail is also NULL.
{
list->head = node;
list->tail = node;
list_exist = 1;
}
else if(list->head == list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
else if(list->head != list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
(list->number_of_nodes)++;
}
void remove_list(struct linked_list*
list)//
{
~~~~~~~~~~~ //your code starts from
here
int deleted_nodes = 0;//Please do not erase
these sentences. you should cover these sentences!
int deleted_node_value;
}
}
In: Computer Science
Python query for below:
There are different ways of representing a number. Python’s function isdigit() checks whether the input string is a positive integer and returns True if it is, and False otherwise. You are to make a more generalised version of this function called isnumeric().
Just like isdigit(), this function will take input as a string and not only return a Boolean True or False depending on whether the string can be treated like a float or not, but will also return its float representation up to four decimal places if it is True.
Remember that numbers can be represented as fractions, negative integers, and float only. Check the sample test cases to understand this better.
Input: One line of string. The string will contain alphabets, numbers and symbols: '/' '.' '^'
Output: One line with True/False and then a space and the number with 4 decimal places if it is true and ‘nan’ if it is false
Sample Input 1: .2
Sample Output 1:
True 0.2000
Sample Input 2: 1 /. 2
Sample Output 2:
True 5.0000
Sample Input 3: 3^1.3
Sample Output 3:
True 4.1712
Sample Input 4: 3/2^3
Sample Output 4:
False NaN
Explanation:
if '^' and '/' are both present then give False. Since it is
ambiguous, 2^5/5 can be seen as 2^(5/5) or (2^5)/5 likewise 3/2^3
can be seen as 3/(2^3) or (3/2)^3
Sample Input 5: 1.2.3
Sample Output 5:
False NaN
Sample Input 6: -2.
Sample Output 6:
True -2.0000
In: Computer Science
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart instance should contain a BagInterface implementation that will serve to hold the Items that will be added to the cart. Use the implementation of the Item object provided in Item.java. Note that the price is stored as the number of cents so it can be represented as an int (e.g., an Item worth $19.99 would have price = 1999).
Using the CLASSES BELOW Your shopping cart should support the following operations:
Add an item
Add multiple quantities of a given item (e.g., add 3 of Item __)
Remove an unspecified item
Remove a specified item
Checkout – should "scan" each Item in the shopping cart (and display its
information), sum up the total cost and display the total cost
Check budget – Given a budget amount, check to see if the budget is large
enough to pay for everything in the cart. If not, remove an Item from the shopping cart, one at a time, until under budget.
Write a driver program to test out your ShoppingCart implementation.
*Item Class*
/**
* Item.java - implementation of an Item to be placed in ShoppingCart
*/
public class Item
{
private String name;
private int price;
private int id;//in cents
//Constructor
public Item(int i, int p, String n)
{
name = n;
price = p;
id = i;
}
public boolean equals(Item other)
{
return this.name.equals(other.name) && this.price == other.price;
}
//displays name of item and price in properly formatted manner
public String toString()
{
return name + ", price: $" + price/100 + "." + price%100;
}
//Getter methods
public int getPrice()
{
return price;
}
public String getName()
{
return name;
}
}
BAG INTERFACE CLASS
/**
* BagInterface.java - ADT Bag Type
* Describes the operations of a bag of objects
*/
public interface BagInterface<T>
{
//getCurrentSize() - gets the current number of entries in this bag
// @returns the integer number of entries currently in the bag
public int getCurrentSize();
//isEmpty() - sees whether the bag is empty
// @returns TRUE if the bag is empty, FALSE if not
public boolean isEmpty();
//add() - Adds a new entry to this bag
// @param newEntry - the object to be added to the bag
// @returns TRUE if addition was successful, or FALSE if it fails
public boolean add(T newEntry);
//remove() - removes one unspecified entry from the bag, if possible
// @returns either the removed entry (if successful), or NULL if not
public T remove();
//remove(T anEntry) - removes one occurrence of a given entry from this bag, if possible
// @param anEntry - the entry to be removed
// @returns TRUE if removal was successful, FALSE otherwise
public boolean remove(T anEntry);
//clear() - removes all entries from the bag
public void clear();
//contains() - test whether this bag contains a given entry
// @param anEntry - the entry to find
// @returns TRUE if the bag contains anEntry, or FALSE otherwise
public boolean contains(T anEntry);
//getFrequencyOf() - count the number of times a given entry appears in the bag
// @param anEntry - the entry to count
// @returns the number of time anEntry appears in the bag
public int getFrequencyOf(T anEntry);
//toArray() - retrieve all entries that are in the bag
// @returns a newly allocated array of all the entries in the bag
// NOTE: if bag is empty, it will return an empty array
public T[] toArray();
}
In: Computer Science
simple Java project// All variables have descriptive names or comments describing their purpose. Thank you Read from a file that contains a paragraph of words. Put all the words in an array, put the valid words (words that have only letters) in a second array, and put the invalid words in a third array. Sort the array of valid words using Selection Sort. Create a GUI to display the arrays using a GridLayout with one row and three columns. The input file Each line of the input file will contain a sentence with words separated by one space. Read a line from the file and use a StringTokenizer to extract the words from the line. An example of the input file would be:
Mary had a little lamb whose fl33ce was white as sn0w And everywhere that @Mary went the 1amb was sure to go. You should have two files to submit for this project: Project1.java WordGUI.java
In: Computer Science