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
JAVA Input a phrase from the keyboard, if the phrase contains "red" or "RED" print out "red" . if the phrase contains "blue" or "BLUE" output "blue" In all other cases print "No Color" For example: If the input was "Violets are BLUE" your output should be "blue" If the input was "Singing the blues" output "blue" If the input was "I have a pure bred puppy" your output should be "red" If the input was "Today is Monday" output "No color". If the input was "My shirt is Blue" output "No color". (because you are only looking for "blue", "BLUE", "red", "RED")
In: Computer Science
You are required to solve the problem on Terrain Navigation.
Terrain navigation is a key component in the design of unmanned aerial vehicles (UAVs). Vehichles such as a robot or a car, can travel on land; and vehiches such as a drone or a plane can fly above the land. A UAV system contains an on board computer that has stored the terrain information for the area in which it is to be operated, Because it knows where it is at all times (often using a global positioning system (GPS) receiver), the vehicle can then select the best path to get to a designed spot. If the destination changes, the vehicle can refer to its internal maps and recompute the new path. The computer software that guides these vechicles must be tested over a variety of land formations and topologies. Elevvation information for large grids of land is available in computer databases. One way of measuring the "difficulty" of a lanad grid with respect to terrain navigation is to determine the number of peaks in the grid, where a peak is a point that has lower elevations all around it. For this problem, we want to determine whether the value in grid position [m] [n] is peak. Assume that the values in the four positions shown are adjacent to grid position [m] [n]:
| grid [m-1] [n] | ||
|---|---|---|
| grid [m][n-1] | grid [m][n] | grid [m][n+1] |
| grid [m+1] [n] |
Write a program that reads elevation data from a data file named grid1. txt. (this file you have to create and name it as grid 1.txt.) data as shown below which represent elevation for a grid that has 6 points along the side and seven points along the top ( the peaks have been highlighted and underlined):
5039 5127 5238 5259 5248 5310 5299
5150 5392 5410 5401 5352 5820 5321
5290 5560 5490 5421 5530 5831 5210
5110 5429 5430 5411 5459 5630 5319
4920 5129 4921 5821 4722 4921 5129
5023 5129 4822 4872 4794 4862 4245
Then prints the number of peaks and their locations. Assume that the first line of the data file contains the number of rows and the number of columns for the grid of information. These values are then followed by the elevation values, in row order. The maximum size of the grid is 25 rows by 25 columns.
Hints:
In: Computer Science
course: Applications of mobile application development
Complete the tasks listed and submit in a word document with 3 pages length
In: Computer Science
Assignment
Pokedex.py:
1,bulbasaur,318,grass,poison 2,ivysaur,405,grass,poison 3,venusaur,525,grass,poison 4,charmander,309,fire 5,charmeleon,405,fire 6,charizard,534,fire,flying 7,squirtle,314,water 8,wartortle,405,water 9,blastoise,530,water 10,caterpie,195,bug 11,metapod,205,bug 12,butterfree,395,bug,flying 13,weedle,195,bug,poison 14,kakuna,205,bug,poison 15,beedrill,395,bug,poison 16,pidgey,251,normal,flying 17,pidgeotto,349,normal,flying 18,pidgeot,479,normal,flying 19,rattata,253,normal 20,raticate,413,normal 21,spearow,262,normal,flying 22,fearow,442,normal,flying 23,ekans,288,poison 24,arbok,448,poison 25,pikachu,320,electric 26,raichu,485,electric,psychic 27,sandshrew,300,ground 28,sandslash,450,ground 29,nidoran,275,poison 30,nidorina,365,poison 810,yeet,777,steel,fire,water,grass,electric,psychic,ice,dragon,dark,fairy,???
Transcript:
1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 1 The Pokedex ----------- Number: 1, Name: Bulbasaur, CP: 318: Type: grass and poison Number: 2, Name: Ivysaur, CP: 405: Type: grass and poison Number: 3, Name: Venusaur, CP: 525: Type: grass and poison Number: 4, Name: Charmander, CP: 309: Type: fire Number: 5, Name: Charmeleon, CP: 405: Type: fire Number: 6, Name: Charizard, CP: 534: Type: fire and flying Number: 7, Name: Squirtle, CP: 314: Type: water Number: 8, Name: Wartortle, CP: 405: Type: water Number: 9, Name: Blastoise, CP: 530: Type: water Number: 10, Name: Caterpie, CP: 195: Type: bug Number: 11, Name: Metapod, CP: 205: Type: bug Number: 12, Name: Butterfree, CP: 395: Type: bug and flying Number: 13, Name: Weedle, CP: 195: Type: bug and poison Number: 14, Name: Kakuna, CP: 205: Type: bug and poison Number: 15, Name: Beedrill, CP: 395: Type: bug and poison Number: 16, Name: Pidgey, CP: 251: Type: normal and flying Number: 17, Name: Pidgeotto, CP: 349: Type: normal and flying Number: 18, Name: Pidgeot, CP: 479: Type: normal and flying Number: 19, Name: Rattata, CP: 253: Type: normal Number: 20, Name: Raticate, CP: 413: Type: normal Number: 21, Name: Spearow, CP: 262: Type: normal and flying Number: 22, Name: Fearow, CP: 442: Type: normal and flying Number: 23, Name: Ekans, CP: 288: Type: poison Number: 24, Name: Arbok, CP: 448: Type: poison Number: 25, Name: Pikachu, CP: 320: Type: electric Number: 26, Name: Raichu, CP: 485: Type: electric and psychic Number: 27, Name: Sandshrew, CP: 300: Type: ground Number: 28, Name: Sandslash, CP: 450: Type: ground Number: 29, Name: Nidoran, CP: 275: Type: poison Number: 30, Name: Nidorina, CP: 365: Type: poison Number: 810, Name: Yeet, CP: 777: Type: steel and fire and water and grass and electric and psychic and ice and dragon and dark and fairy and ??? 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 2 Enter a Pokemon name: RAICHU Number: 26, Name: Raichu, CP: 485: Type: electric and psychic 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 2 Enter a Pokemon name: raichump There is no Pokemon named raichump 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 3 Enter a Pokemon number: 26 Number: 26, Name: Raichu, CP: 485: Type: electric and psychic 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 3 Enter a Pokemon number: 34 There is no Pokemon number 34 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 4 Enter a Pokemon type: Normal Number of Pokemon that contain type normal = 7 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 4 Enter a Pokemon type: ??? Number of Pokemon that contain type ??? = 1 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 4 Enter a Pokemon type: unknown Number of Pokemon that contain type unknown = 0 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 5 Average Pokemon combat points = 370.71 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 6 Thank you. Goodbye!
Grading - 100 points
In: Computer Science
Find Consider the following context-free grammar G:
S --> T#T
T --> C
A --> aA | epsilon
B --> bB | epsilon
C --> cC
C --> c
a) Give the set of unproductive symbols in G?
b) Give an equivalent grammar without useless symbols.
In: Computer Science
(JAVA)
Balanced
Class diagram:
Balanced
+ swing(int[] a) : boolean
For this exercise, you will have to implement the class diagram
above. Basically, the objective of this exercise is to develop the
class and the previous method, in such a way that it tells us if an
array is balanced or not.
We say that an array is balanced if the sum of the elements belonging to the first half of the array (not including the element in the middle), and the sum of the elements belonging to the second half of the array (not including the element in the middle) They are equal.
Example 1: the balance method receives the array [1,2,3,4,2]
The method returns false
Example 2: the balance method receives the array [1,2,78,3,0]
The method returns true
TIP: for this exercise, ONLY odd arrangements will be made.
In: Computer Science
Write a JAVA program to store some details of pizzas (menu item
number, size, base, extra cheese, extra
garlic), curries (menu item number, size, curry type) and
softdrinks (menu item number, size,
flavour, bottle or can) in a single array, with the options of
listing all menu items or deleting a
particular menu item.
Your program must continuously prompt the user to choose an option
from a list and act on that
option, until the exit option is chosen. (See the sample output
below.) If a menu item is not found,
output "Not found" instead of "Done".
You must use inheritance and polymorphism to model your Pizza,
Curry and SoftDrink classes (use
those exact class names) as subclasses of the same base class,
which forms the basis for the array.
Note: Be very careful to reproduce the output exactly.
Copy-and-paste is highly recommended to
avoid minor typographical errors that drive you crazy when
submitting online!
Sample Input/Output:
Welcome to Great International Food Court
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete,
(L)ist,
(Q)uit
p
Enter the menu item number
123
Enter the size
12"
Enter the base
Hand-tossed
Enter extra cheese
Yes
Enter extra garlic
Yes
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist,
(Q)uit
c
Enter the menu item number
456
Enter the size
Large
Enter the curry type
Vindaloo
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist,
(Q)uit
s
Enter the menu item number
789
Enter the size
Large
Enter the flavour
Coke
Enter whether it is a bottle or can
Bottle
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist,
(Q)uit
d
Enter the menu item number
456
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist,
(Q)uit
l
Pizza: 123, 12", Hand-tossed, Yes, Yes
Soft Drink: 789, Large, Coke, Bottle
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist,
(Q)uit
q
In: Computer Science