Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output.(In Python)
In: Computer Science
In: Computer Science
Answer question in Python, show all code
2) Recall the palindrome problem. Write a new program that prompts the user for a string and checks to see if that string is a palindrome. For this updated program, input strings may have punctuation marks, spaces, and capitalizations, but these are ignored in the palindrome check. Here are some sample interactions.
Please enter a string to check: A man, a plan, a canal: Panama!
The string "A man, a plan, a canal: Panama!" is a palindrome.
Please enter a string to check: No ‘x’ in Nixon
The string "No ‘x’ in Nixon" is a palindrome.
Please enter a string to check: hello students
The string "hello students" is not a palindrome.
Hint: Note that you already know how to check if a string is a palindrome, as long as that string doesn’t include punctuation marks, spaces and both upper and lower case characters. Therefore, your job here is to figure out how to get the input string transformed into a string that does not include these things, and then do the same check you did before
In: Computer Science
Please solve everything using Python 3
1. What does list contain after the following code is executed?
list = [82, 27, 66, 18, 40, 93, 85, 29]
list.append(50)
list.insert(3, 99)
list.pop()
a. [82, 27, 66, 99, 18, 40, 93, 85, 29]
b. [50, 82, 27, 99, 66, 18, 40, 93, 85]
c. [27, 66, 99, 18, 40, 93, 85, 29, 50]
d. [82, 27, 99, 66, 18, 40, 93, 85, 29]
2. What does list contain after the following code is executed?
list = [77, 41, 92, 30, 38, 12, 63]
list.sort()
list.insert(2, 88)
list.pop(5)
a. [12, 30, 88, 38, 63, 77, 92]
b. [92, 77, 88, 63, 41, 30, 12]
c. [12, 88, 30, 38, 63, 77, 92]
d. [12, 30, 88, 38, 41, 77, 92]
3. What does the list states contain after the following code is executed?
states = ['NJ', 'TN', 'WI', 'UT']
states.extend(['PA', 'KY', 'NY'])
states.remove('UT')
states.sort(reverse=True)
a. ['WI', 'UT', 'TN', 'PA', 'NY', 'NJ', 'KY']
b. ['WI', 'PA', 'TN', 'NJ', 'NY', 'KY']
c. ['WI', 'TN', 'PA', 'NY', 'NJ', 'KY']
d.['NJ', 'TN', 'WI', 'PA', 'KY', 'NY']
In: Computer Science
1-List the different ways to represent signed integers and represent (-75) in these ways.
Convert the following:
Find the two's complement for the following
2- Compute the following signed integer and determine if either there carry or overflow
In: Computer Science
Using C++. Implement l_list.cpp and l_list.h
l_list and encounterNode. The former is a richly featured linked list with a wide variety of methods and the latter is a node meant to encapsulate a game encounter. In the context of this task, the encounterNode represents a battle encounter. Each encounter will describe what a player has to watch in the course of the level in terms of enemies, rewards and such. Therefore a combination of encounterNodes contained within a linked list would represent a single level in a game. The classes and behaviors of their methods are detailed below:
l_list
-head: encounterNode*
---------------------------
+l_list()
+~l_list()
+addToFront(a:string*, b:int, c:string):int
+addToBack(a:string*, b:int, c:string):int
+addAtIndex(a:string*, b:int, c:string, index:int):int
+getListSize():int
+removeFromFront():encounterNode*
+removeFromBack():encounterNode*
+removeFromIndex(index:int):encounterNode*
+printSummaryOfList():void
+printList():void
The class has the following variables:
•head: The head pointer which demarcates the start
of the list.
The class has the following methods:
•l_list: The list constructor. It will start by
initialising a blank list with no elements.
•∼l_list: The list destructor. It should delete all of the remaining nodes in the list and deallocate all of the memory contained within. After deleting the list, it should print out the following message: ”Number of nodes deleted: X” without quotation marks where X indicates the number of nodes deleted in the process. Be sure to add a newline at the end of this output.
•addToFront: This method receives the variables to construct a new node and then allocates memory for it before adding it to the list at the front. It returns the new size of the list, that is the size of the list with the added node.
•addToBack: This method receives the variables to construct a new node and then allocates memory for it before adding it to the list at the back of the list. It returns the new size of the list, that is the size of the list with the added node.
•addAtIndex: This method receives the variables required to instantiate a new node as well as an index. This method should insert this node into the list at the given index. If the given index is not contained within the list, such as inserting at 5 when the list is only 2 nodes big, instead you must add it to the front. Note that the list is 0-indexed. It returns the new size of the list, that is the size of the list with the added node.
•getListSize: This method determines the number of nodes in the list and returns this as an integer.
•removeFromFront: This remove method removes a node from the list from the front and returns it. Note that the node is returned and not deleted; it must be properly unlinked from the list without being destroyed. If the list is empty, return NULL.
•removeFromBack: This remove method removes a node from the list from the back and returns it. Note that the node is returned and not deleted; it must be properly unlinked from the list without being destroyed. If the list is empty, return NULL.
•removeFromIndex: This method receives an index of a node to remove from the list. This node must be removed and returned without being destroyed; that is, unlinked from the list without being deleted. Note that if the index is not valid or the list is empty then the method should return NULL. The list is 0-indexed.
•printList: This method prints out the entire
list, starting from the front. If the list is empty, print ”EMPTY
LIST” without the quotation marks and a newline at the end. The
example output is given below:
Node 0
Number of Enemies: 2
Reward: Boots of Healing
Enemy 1: Imp
Enemy 2: Imp
Node 1
Number of Enemies: 2
Reward: Sword of Revealing
Light
Enemy 1: Mancubus
Enemy 2: Hell Knight
•printSummaryOfList: This method is a more
sophisticated type of print. Instead of merely printing out of the
full information of the list, it aggregates and collates the
information from the list into a more easily readable report. If
the list is empty,
print ”EMPTY LIST” without the quotation marks and a newline at the
end. The report determines the following pieces of
information:
1.The number of nodes in the
list.
2.The number of enemies, in total
in the list.
3.The number of rewards which are
healing to the player, that is if the reward has Healing or Health
in its name. You can assume that the case will match the specific
form of Healing or Health.
Therefore the output of this print operation takes the form
(considering the prior example as the list):
Number of Nodes: 2
Number of Enemies: 4
Number of Healing Rewards: 1
You are only allowed the use of the following libraries: string and iostream.
===================encounterNode.h=====================
#ifndef ENCOUNTER_NODE_H
#define ENCOUNTER_NODE_H
#include<iostream>
#include<string>
using namespace std;
class encounterNode
{
private:
string* enemies;
int numEnemies;
string reward;
public:
encounterNode* next;
encounterNode(string* list, int
numE, string re);
~encounterNode();
string* getEnemies() const;
void setEnemies(string* a, int
b);
string getEnemyAtIndex(int
a);
void setEnemyAtIndex(int a, string
b);
string getReward() const;
void setReward(string a);
int getNumEnemies() const;
void setNumEnemies(int a);
void print();
};
#endif
===================encounterNode.cpp=====================
#include "encounterNode.h"
#include<iostream>
#include<string>
using namespace std;
encounterNode::encounterNode(string* list, int numE, string
re)
{
enemies = list;
numEnemies = numE;
reward = re;
}
encounterNode::~encounterNode()
{
delete [] enemies;
}
string* encounterNode::getEnemies() const
{
return enemies;
}
void encounterNode::setEnemies(string* a, int b)
{
if (enemies != NULL)
delete[]enemies;
enemies = new string[b];
for (int i = 0; i < b; i++)
enemies[i] = a[i];
numEnemies = b;
}
string encounterNode::getEnemyAtIndex(int a)
{
if (a >= 0 && a < numEnemies)
return enemies[a];
else
return "";
}
void encounterNode::setEnemyAtIndex(int a, string b)
{
if (a >= 0 && a < numEnemies)
enemies[a] = b;
}
string encounterNode::getReward() const
{
return reward;
}
void encounterNode::setReward(string a)
{
reward = a;
}
int encounterNode::getNumEnemies() const
{
return numEnemies;
}
void encounterNode::setNumEnemies(int a)
{
numEnemies = a;
}
void encounterNode::print()
{
cout << "Number of Enemies: " <<
numEnemies << endl;
cout << "Reward: " << reward <<
endl;
for (int i = 0; i < numEnemies; i++)
{
cout << "Enemy " << (i
+ 1) << ": " << enemies[i] << endl;
}
cout << endl;
}
In: Computer Science
this won't compile
package com.test;
public class CatalogItem {
private String title;
private double price;
public CatalogItem(String title, double price) {
super();
this.title = title;
this.price = price;
}
public String getTitle() {
return title;
}
public double getPrice() {
return price;
}
}
//Book.java
package com.test;
public class Book extends CatalogItem {
private String author;
private int ISBN;
public Book(String title, double price, String author, int iSBN) {
super(title, price);
this.author = author;
ISBN = iSBN;
}
public String getAuthor() {
return author;
}
public int getISBN() {
return ISBN;
}
@Override
public String toString() {
return "Title: " + getTitle() + " | Author: "+author + " | Price: " + getPrice() + " ISBN: "+ISBN;
}
}
//AudioBook.java
package com.test;
public class AudioBook extends Book {
private double runningTime;
public AudioBook(String title, double price, String author, int iSBN, double runningTime) {
super(title, price, author, iSBN);
this.runningTime = runningTime;
}
public double getRunningTime() {
return runningTime;
}
public double getP() {
return getPrice()*0.90;
}
@Override
public String toString() {
return "Title: " + getTitle() + " | Author: "+getAuthor() + " | Price: " + getP() + " | ISBN: "+getISBN() + " | running time: "+runningTime;
}
}
//DVD.java
package com.test;
public class DVD extends CatalogItem {
private String director;
private int year;
private int dvdcode;
public DVD(String title, double price, String director, int year, int dvdcode) {
super(title, price);
this.director = director;
this.year = year;
this.dvdcode = dvdcode;
}
public String getDirector() {
return director;
}
public int getYear() {
return year;
}
public int getDvdcode() {
return dvdcode;
}
@Override
public String toString() {
return "Title: " + getTitle() + " | Director: "+director + " | Price: " + getPrice() + " | Year: "+year + " | DvdCode: "+dvdcode;
}
}
//Driver.java
package com.test;
import java.util.ArrayList;
import java.util.Scanner;
public class Driver {
public static ArrayList<Book> booklist = new ArrayList<>();
public static ArrayList<DVD> dvdlist = new ArrayList<>();
public static void display()
{
for(int i=0;i<booklist.size();i++)
{
if(booklist.get(i) instanceof AudioBook)
System.out.println((AudioBook)(booklist.get(i)));
else
System.out.println(booklist.get(i));
}
System.out.println("-------------------------------------------------------------------------------");
for(int i=0;i<dvdlist.size();i++)
{
System.out.println(dvdlist.get(i));
}
}
//method to find book
public static boolean findBook(int isbn)
{
for(int i=0;i<booklist.size();i++)
{
if(booklist.get(i).getISBN() == isbn)
return true;
}
return false;
}
//method to find book
public static boolean findDVD(int dvdcode)
{
for(int i=0;i<dvdlist.size();i++)
{
if(dvdlist.get(i).getDvdcode() == dvdcode)
return true;
}
return false;
}
public static void main(String[] args) {
System.out.println("Welcome to the comets Books and DVDs store(Catalog Section)");
int option;
String title;
double price;
String author;
int isbn;
double runningTime;
String director;
int year;
int dvdcode;
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Choose from the following option:");
System.out.println("1-Add Book");
System.out.println("2-Add AudioBook");
System.out.println("3-Add DVD");
System.out.println("4-Remove Book");
System.out.println("5-Remove DVD");
System.out.println("6-Display Catalog");
System.out.println("9-Exit Store");
option = sc.nextInt();
if(option == 1)
{
System.out.println("Please enter Book isbn");
isbn = sc.nextInt();
if(findBook(isbn))
continue;
System.out.println("Please enter Book title");
title = sc.next();
System.out.println("Please enter Book price");
price = sc.nextDouble();
while(price < 0) {
System.out.println("Please enter Book valid price");
price = sc.nextDouble();
}
System.out.println("Please enter Book author");
author = sc.next();
Book b = new Book(title, price, author, isbn);
booklist.add(b);
}
else if(option == 2)
{
System.out.println("Please enter Audio Book isbn");
isbn = sc.nextInt();
if(findBook(isbn))
continue;
System.out.println("Please enter Audio Book title");
title = sc.next();
System.out.println("Please enter Audio Book price");
price = sc.nextDouble();
while(price < 0) {
System.out.println("Please enter Audio Book valid price");
price = sc.nextDouble();
}
System.out.println("Please enter Audio Book author");
author = sc.next();
System.out.println("Please enter Audio Book running time");
runningTime = sc.nextDouble();
while(runningTime < 0) {
System.out.println("Please enter Audio Book valid running time");
runningTime = sc.nextDouble();
}
AudioBook b = new AudioBook(title, price, author, isbn,runningTime);
booklist.add(b);
}
else if(option == 3)
{
System.out.println("Please enter DVD code");
dvdcode = sc.nextInt();
if(findDVD(dvdcode))
continue;
System.out.println("Please enter DVD title");
title = sc.next();
System.out.println("Please enter DVD price");
price = sc.nextDouble();
System.out.println("Please enter DVD director");
director = sc.next();
System.out.println("Please enter DVD year");
year = sc.nextInt();
DVD d = new DVD(title, price, director, year, dvdcode);
dvdlist.add(d);
}
else if(option == 4)
{
System.out.println("Enter isbn number to delete book");
isbn = sc.nextInt();
boolean remove = false;
for(int i=0;i<booklist.size();i++){
if(booklist.get(i).getISBN() == isbn){
booklist.remove(i);
remove = true;
}
}
if(remove == false)
System.out.println("The Book doesn't exist in catalog");
display();
}
else if(option == 5)
{
System.out.println("Enter dvd code to delete DVD");
dvdcode = sc.nextInt();
boolean remove = false;
for(int i=0;i<dvdlist.size();i++){
if(dvdlist.get(i).getDvdcode() == dvdcode){
dvdlist.remove(i);
remove = true;
}
}
if(remove == false)
System.out.println("The DVD doesn't exist in catalog");
display();
}
else if(option == 6)
{
display();
}
else if(option == 9)
break;
else
System.out.println("This option is not acceptable");
}
}
}
In: Computer Science
In: Computer Science
1) Design an efficient data storage scheme using Normalization steps we have outlined.
2) Create tables as per normalization steps we have discussed in your database
Submit the table creation script and the output of desc
Explain any thing you wish to explain.
Data below:
invoiceno, invoice_date, invoice_amount, vendor, vendor_phone, vendor_address, vendor_preferred_payment_method, verification_date, verified_by, verifier_code, verifier_role_title, approval_date, approved_by, approver_code, approver_role_title, payment_date, payment_by, payer_code, payer_title 211,10/19/2019,2311.45,VIC,673-234-4001,"blah blah,nyc,ny",check:made payable to VIC:net 30d,10/20/2019,Shelley Cramer,SC,ECOM:Project manager,10/20/2019,Zack Swindler,ZS,Sales:Managing Director,10/21/2019,Cathy Zuppa, CZ, Finance:CPA 209,10/10/2019,28750.07,GRC,913-123-3489,"zing zing, Cool,CO",ACH:ABA23457892 FBO GRC:net 30d,10/10/2019,Zack Swindler,ZS,Sales:Managing Director,10/11/2019,Tiny Bulger, TB, COO,10/12/2019,Irwine Ladder,IL,Finance:CFO 203,10/4/2019,17000.45,NightCrawler,873-318-7777,"Blue Lagoon,Torch,AZ",check:made payable to NCH:net 60d,10/7/2019,Zack Swindler,ZS,Sales:Managing Director,10/8/2019,Shelley Cramer, SC, ECOM:Project Manager,10/12/2019,Cathy Zuppa, CZ, Finance:CPA 181,10/1/2019,2311.45,VIC,673-234-4001,"blah blah,nyc,ny",check:made payable to VIC:net 60d,10/2/2019,Zack Swindler,ZS,Sales:Managing Director,10/3/2019,Martin Short,MS,Sales:Managing Director,10/21/2019,Cathy Zuppa, CZ, Finance:CPA
In: Computer Science
Complete the following: (With Details and example if needed)
Given set S = {-3, -2, 0, 1, 2, 4}
Relation R is a relation on S such that R = { (?, ?) | ? ∈ ?, ? ∈ ? ??? ?? ≥ 1}
1. Using roster method, what is R?
2. Show the digraph representation of R
3. Show the matrix representation of R
4. if the relation does not have the property, give an example of why:
- Is R reflexive?
- Is R symmetric?
-Is R antisymmetric?
- Is R transitive?
In: Computer Science
A zombie picks up a calculator and starts adding odd whole numbers together, in order: 1 + 3 + 5......etc. You want to be able to determine the last number the zombie will add that will make the sum exceed some target number, such as "What will be the last number added that will make the sum on his calculator greater than 10,000?".
Write the MATLAB code necessary to solve this problem for the zombie or he will eat your brain. Create a function with an input of the target number (in the scenario given above the target number would be 10,000), which outputs the last numbered added.
In: Computer Science
In: Computer Science
Answer question in Python, show all code:
Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed from the account over this period.
Your program output should look like this:
Balance after year 1 is $ 1060.0
Balance after year 2 is $ 1123.6
Balance after year 3 is $ 1191.02
Balance after year 4 is $ 1262.48
Balance after year 5 is $ 1338.23
In: Computer Science
In: Computer Science
Sorting algorithm for arrays: understand how to perform the following algorithms. (a). Simple sorting
Bubblesort:T(n)ÎO(n2)
Selection sort : T(n) Î O(n2)
Insertion sort: T(n) Î O(n2)
(b).Advanced sorting
i. Shell sort: O(n2) < O(n1.25) < O(nlogn), O(n1.25) is empirical result for shell sort.
Merge sort: T(n) Î O(nlogn), need one temporary array with the same length as the array needed to be sorted.
Quick sort: -average case: T(n) Î O(nlogn),
-worst case(rare occurrence): T(n) Î O(n2)
5. Searching algorithm for arrays: understand how to perform the following algorithms. (a). Searching in unsorted arrays
i. Sequentialsearch
ii. Sequential search with sentinel
(b).Searching in sorted arrays
Binary search
Interpolation search
In: Computer Science