Questions
Consider the following ER diagram, which models an online bookstore. As per the attached picture in...

Consider the following ER diagram, which models an online bookstore.

As per the attached picture in the attached link :
https://www.google.com/imgres?imgurl=https://media.cheggcdn.com/study/45a/45a5708f-f2b8-4864-99a3-284d8c13e235/5924-7-20EEI1.png&imgrefurl=https://www.chegg.com/homework-help/consider-e-r-diagram-figure-729-models-online-bookstore-lis-chapter-7-problem-20e-solution-9780073523323-exc&tbnid=q173_TY0HXF25M&vet=1&docid=hPpMlzEq8SYJYM&w=756&h=688&hl=en&source=sh/x/im

A. List the entity sets and their primary keys.

B. Map the ER to appropriate schema showing the different relations.

In: Computer Science

In php: This is a static website. There are missing parts that students must fill in...

In php:

  • This is a static website.
  • There are missing parts that students must fill in in order to have a working website.
  • Students should follow the comments in the php file to complete this part.

After completed, the website should hide all messages before the user click submit button OR show either the error message or success message if the user click submit button.

//code

<?php

   if(isset($_GET['submit'])){

//sanitize the input
      
/* Check the error from the input:
if input from user is empty
-> get an error string variable
if input is not empty
-> use preg_match() to match the pattern
$pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/";
-> if it's a matched, get a success string variable
*/
      
   }
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="">
<title>Lab 2-Part1</title>
</head>
<body>

   <form action="" class="main-form needs-validation">
<div class="form-group">
<label for="numbers">Phone Number</label>
<input type="text" id="numbers" class="form-control" value=<?php //use PHP to print out the value the use typed in if any ?>>
<small class="form-text text-muted">xxx.xxx.xxx or xxx-xxx-xxxx</small>
<!-- Set a condition
if there is an error string variable, print out the string in PHP
if there is a success string variable, print out the string in PHP
-->
      <div class="alert alert-danger">
          Must enter a valid phone number! <!-- should be from an error string variable -->
          </div>
          <div class="alert alert-success">
          Phone number is valid! <!-- should be from an error string variable -->
          </div>
</div>
  
<button type="submit" class="btn btn-primary" >Submit</button>
</form>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
</body>
</html>

In: Computer Science

Write a Python program that reads an integer and prints how many digits the number has,...

Write a Python program that reads an integer and prints how many digits the number has, by checking whether the number is ≥10,≥100,≥1000, and so on (up to 1,000,000). Your program should also identify if a number is negative.

In: Computer Science

Create a webpage with HTML and JAVA Script that takes a user's 4 inputs (first name,...

Create a webpage with HTML and JAVA Script that takes a user's 4 inputs (first name, last name, phone number, and sex[using checkbox, must set on load and change whenever the checkbox is selected, only 1 box can be selected, selecting the other automatically deselects the latter])

The first button saves all the inputs into LOCAL STORAGE

The Second button retrieves all the data in LOCAL STORAGE and displays them on the same page. Alert box to inform the user the button was selected.

The third button to clear the sex designation key/value pair in LOCAL STORAGE. Alert Box to inform the use the button was selected.

In: Computer Science

//instructions Form: There should be at least 2 input fields for username and password. Use an...

  • //instructions
  • Form:
    • There should be at least 2 input fields for username and password.
  • Use an array as a database in which there are several usernames and passwords:
    • Usernames can be either emails or nick names (WITHOUT WHITE SPACE)
  • After the user submitted the form, students must:
    • sanitize the inputs
    • check if there is a match with one username and one password in the array.
    • If there is no match, print out an error message to user on the form.
    • If it is a match, redirect the user to a welcome page.

//code

   if(isset($_GET['submit'])){

//sanitize the input
      
/* Check the error from the input:
if input from user is empty
-> get an error string variable
if input is not empty
-> use preg_match() to match the pattern
$pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/";
-> if it's a matched, get a success string variable
*/
      
   }
?>






Lab 2-Part1

  



Phone Number
>
xxx.xxx.xxx or xxx-xxx-xxxx


     


          Must enter a valid phone number!
         


         


          Phone number is valid!
         



  
Submit






In: Computer Science

Write a program in c++ using only while and for loops . Use of arrays and...

Write a program in c++ using only while and for loops . Use of arrays and functions is not allowed.

Given the first value, generate the next ten terms of the sequence like 1, 2, 4, 8, 16, 22, 26,
38, 62, 74, 102, 104, …

Explaination with code is required.

In: Computer Science

You are to write a class StringPlay that has only a main method. This class contains...

You are to write a class StringPlay that has only a main method. This class contains all interaction with the user.

The main method

  • Uses a Scanner to accept user input
  • Maintains a “currentString
  • Uses a sentinel-controlled loop to accept multiple user commands, or exit
  • The program displays a message asking the user to enter one of the following commands
    • a – enter a new value for current
    • b – padLeft asks the user for the number of characters to add to the start of the current string, and the character to use for the padding
    • c – padRight asks the user for the number of characters to add to the end of the current string, and the character to use for the padding
    • d – zapLeft asks the user for the number of characters to remove from the start of the current string
    • e – zapRight asks the user for the number of characters to remove from the end of the current string
    • f – exits the program
  • The loop body performs its actions using the appropriate method from StringUtils.
  • After the action is completed, the loop displays the current string and prompts for another command.

Notes

Use Scanner’s next method for the “e” command; we will limit our user input to have no spaces or other whitespace. Similarly, padding characters will not be whitespace. You may assume valid user input.

In: Computer Science

Describe how frame transmission takes place in a LAN with a physical ring topology.

Describe how frame transmission takes place in a LAN with a physical ring topology.

In: Computer Science

JAVA PROGRAM The Florida Dental Association needs a simple program to record what teeth the members...

JAVA PROGRAM

The Florida Dental Association needs a simple program to record what teeth the members of Florida families have. Different Floridians have different numbers of different types of teeth (the program must use this simplified categorization of types of teeth):

  • Biting teeth (the 'B' teeth)
  • Chewing teeth (the 'C' teeth)
  • Missing teeth (the 'M' teeth)

The program must record the teeth for one Florida family. When it starts the program asks how many people there are in the family (maximally 5), then for each family member gets their name, a string of tooth types for the uppers (maximally 10 teeth including missing teeth), and a string a tooth types for the lowers (maximally 10 teeth), e.g., the string "CMCBBBMCCM" would represent 10 teeth (of which three are missing). The names are recorded in an array of strings. The tooth information is recorded in a three dimensional array of characters, where each plane corresponds to a person, there are two rows for uppers and lowers, and each row has a column for each tooth. Once the information is recorded the program must offer a menu of four options:

  1. Print the family's teeth record.
  2. Extract a tooth (with a check that there is something there to remove).
  3. Report the family's root canal indices, which are the roots of the quadratic equation Bx2 + Cx - M, where B, C, and M are the family's numbers of those types of teeth.
  4. Exit (with a smile)

The program must be reasonably idiot proof:

  • Menu options must be accepted in upper and lower case.
  • Tooth letters must be accepted in upper and lower case.
  • All input must be checked to be in range, and if not the user must be asked to input again.
  • You may assume that numeric input will be syntactically correct.

Here's what a sample run should look like (with the keyboard input shown in italics) ...

Welcome to the Floridian Tooth Records
--------------------------------------
Please enter number of people in the family : -3
Invalid number of people, try again         : 7
Invalid number of people, try again         : 3
Please enter the name for family member 1   : Henrietta
Please enter the uppers for Henrietta       : ABCDEFGHIJ
Invalid teeth types, try again              : BBBCMCBBBMCCMBBB
Too many teeth, try again                   : CMCBBBMCCM
Please enter the lowers for Henrietta       : CCMBBMCC
Please enter the name for family member 2   : Stanley
Please enter the uppers for Stanley         : mbbm
Please enter the lowers for Stanley         : ccMMcc
Please enter the name for family member 3   : Raul
Please enter the uppers for Raul            : CCBbbcC
Please enter the lowers for Raul            : ccbBBCC

(P)rint, (E)xtract, (R)oot, e(X)it          : T
Invalid menu option, try again              : p

Henrietta
  Uppers:  1:C  2:M  3:C  4:B  5:B  6:B  7:M  8:C  9:C 10:M
  Lowers:  1:C  2:C  3:M  4:B  5:B  6:M  7:C  8:C
Stanley
  Uppers:  1:M  2:B  3:B  4:M
  Lowers:  1:C  2:C  3:M  4:M  5:C  6:C
Raul
  Uppers:  1:C  2:C  3:B  4:B  5:B  6:C  7:C
  Lowers:  1:C  2:C  3:B  4:B  5:B  6:C  7:C

(P)rint, (E)xtract, (R)oot, e(X)it          : E
Which family member                         : Melanie
Invalid family member, try again            : stanley
Which tooth layer (U)pper or (L)ower        : M
Invalid layer, try again                    : u
Which tooth number                          : 27
Invalid tooth number, try again             : 4
Missing tooth, try again                    : 2

(P)rint, (E)xtract, (R)oot, e(X)it          : P

Henrietta
  Uppers:  1:C  2:M  3:C  4:B  5:B  6:B  7:M  8:C  9:C 10:M
  Lowers:  1:C  2:C  3:M  4:B  5:B  6:M  7:C  8:C
Stanley
  Uppers:  1:M  2:M  3:B  4:M
  Lowers:  1:C  2:C  3:M  4:M  5:C  6:C
Raul
  Uppers:  1:C  2:C  3:B  4:B  5:B  6:C  7:C
  Lowers:  1:C  2:C  3:B  4:B  5:B  6:C  7:C

(P)rint, (E)xtract, (R)oot, e(X)it          : R
One root canal at     0.40
Another root canal at -2.07

(P)rint, (E)xtract, (R)oot, e(X)it          : X

Exiting the Floridian Tooth Records :-)

In: Computer Science

Hi, I don’t know why I keep getting this error and I’ve spent a while on...

Hi, I don’t know why I keep getting this error and I’ve spent a while on it now. I am coding in C++.

Here is my .h

___

#ifndef CARD_H
#define CARD_H

#include <iostream>
#include <string>
using namespace std;

class Card 
{
    private: 
    
    int powerLevel;
    string element;
    
    public:
    
    Card();
    Card(string, int);
    string getElement();
    int getPowerLevel();
    void displayCard();
};

#endif

___

Here is my .cpp

___

#include <iostream>
#include "Card.h"
#include <string>
using namespace std;

Card::Card()
{
    element = "";
    powerLevel = 0;
}

Card::Card(string e, int a)
{
    element = e;
    powerLevel = a;
}

string Card::getElement()
{
    return element;
}

int Card::getPowerLevel()
{
    return powerLevel;
}

void Card::displayCard()
{
    cout << element << "-" << powerLevel << endl;
}

___

This is the error message

___

/tmp/ccOrFltm.o: In function `Card::Card()':
Card.cpp:(.text+0x0): multiple definition of `Card::Card()'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0x0): first defined here
/tmp/ccOrFltm.o: In function `Card::Card()':
Card.cpp:(.text+0x0): multiple definition of `Card::Card()'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0x0): first defined here
/tmp/ccOrFltm.o: In function `Card::Card(std::string, int)':
Card.cpp:(.text+0x64): multiple definition of `Card::Card(std::string, int)'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0x64): first defined here
/tmp/ccOrFltm.o: In function `Card::Card(std::string, int)':
Card.cpp:(.text+0x64): multiple definition of `Card::Card(std::string, int)'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0x64): first defined here
/tmp/ccOrFltm.o: In function `Card::getElement()':
Card.cpp:(.text+0xd0): multiple definition of `Card::getElement()'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0xd0): first defined here
/tmp/ccOrFltm.o: In function `Card::getPowerLevel()':
Card.cpp:(.text+0xfe): multiple definition of `Card::getPowerLevel()'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0xfe): first defined here
/tmp/ccOrFltm.o: In function `Card::displayCard()':
Card.cpp:(.text+0x10e): multiple definition of `Card::displayCard()'
/tmp/ccRpEdKb.o:Card.cpp:(.text+0x10e): first defined here
collect2: error: ld returned 1 exit status

___

Thank you for your time

In: Computer Science

Explain in detail instruction cycle. Explain the architecture of 8085 register.

Explain in detail instruction cycle.
Explain the architecture of 8085 register.

In: Computer Science

Exercise: Advanced counting Complete the program below in the answer box by entering functions so the...

Exercise: Advanced counting

Complete the program below in the answer box by entering functions so the program can modify the value variable either by adding 1, adding 5, subtracting 1, or subtracting 5. There should only be one function updating the value. The functions subtract_one, add_one, etc. are helper functions as described above; they should simply call the value update function.

from tkinter import *
from tkinter.ttk import *

# Write your functions here

def main():
"""Set up the GUI and run it"""

global value, value_label
window = Tk()
value = 0
value_label = Label(window, text=str(value))
value_label.grid(row=0, column=0, columnspan=4)
subtract_five_button = Button(window, text="-5", command=subtract_five)
subtract_five_button.grid(row=1, column=0)
subtract_one_button = Button(window, text="-1", command=subtract_one)
subtract_one_button.grid(row=1, column=1)
add_one_button = Button(window, text="+1", command=add_one)
add_one_button.grid(row=1, column=2)
add_five_button = Button(window, text="+5", command=add_five)
add_five_button.grid(row=1, column=3)
window.mainloop()

main()

In: Computer Science

A file name is supposed to be in the form filename , ext . Write a...

A file name is supposed to be in the form filename , ext . Write a function that will determine whether a string is in the form of a name followed by a dot followed by a three - character extension , or not . The function should return 1 for logical true if it is in that form , or 0 for false if not ,

In: Computer Science

3 Design 3.1 Token Class The Token type, which is an enum type and used in...

3 Design
3.1 Token Class

The Token type, which is an enum type and used in the Token class, is defined as follows:

enum Token_type {ID, INT, OP, EQ, OpenBrace, CloseBrace, INVALID};

If string s, passed in to the constructor or set method, is an identifier then the token type is ID; is a nonnegative integer then the token type is INT; is one of +, -, *, / then the token type is OP; is = then the token type is EQ; is (, open parenthesis, then the token type is OpenBrace; is ), close parenthesis, then the token type is CloseBrace; is none of the above then the token type is INVALID. The constructor and set method are required to figure out the type of a token string.

Token class is used to store a “token”, which has three members and a few member functions. The members are:

type This field stores the type of the token. Its type is Token type whose definition is given earlier.

token This field stores the token. Its type is string.
priority This field stores the priority of the token when token is an operator

or a parenthesis. Its type is int. The member functions are:

Token() This default constructor initializes type to INVALID, token to empty string, and priority to -1.

Token(string s) This constructor takes in a string and treats it as a token. It sets the type and token member accordingly. For the current project, it sets the priority member to -1.

void set(string s) This method takes in a string and treats it as a token. It sets the members based on the new token s. Again, for the current project, it sets the priority member to -1.

2

int value() const This method returns the value associated with the token when token type is integer or identifier. In this assignment, if the type is INT, the integer represented as a string stored in token member should be converted to int and returned; if the type is ID, it returns -1; for all other types, it returns -2.

In the future assignment, we will be able to process assignment statement such as x=5 and a symbol table is used to associate x with 5. In this case, for token x, the function returns 5.

void display() const This method outputs the values of the token members in three lines. Each line begins with the member name, followed by “=”, followed by the value. This method is mainly for debugging use. For example, if token string is a12, we have:

     type = ID
     token = a12 (value is -1)
     priority = -1

Token type get type() const Getter for type member. string get token() const Getter for token member.
int get priority() const Getter for priority member.

Typically during the tokenizing process of the input string, we get a sequence of characters stored in a string, which is a token. We then use Token class via its constructor or set method to figure out if the token is valid or not and what type of token it is and so on. That is perhaps the most challenging programming (algorithmic) task for the implementation of the Token class. Since an expression is really a sequence of tokens in an abstract sense, the Token class is used by the Expression class to be designed next.

Since none of the member of the Token class involves pointer type and mem- ory allocation, the default copy constructor and assignment operator provided by the compiler should work just fine. We do not need to implement them.

3.2 Expression Class

The Exp type type, which is an enum type and used in the Expression class, is defined as follows:

enum Exp_type {ASSIGNMENT, ARITHMETIC, ILLEGAL};

For the current assignment, we are not required to figure out the type of an expression. We will do that in a later assignment. For the current project, we treat an expression in two ways: 1) as a string and 2) as a sequence of tokens (Token objects stored in a vector) obtained from the string.

Expression class is used to store an “expression”, which has five members and a few member functions. The members are:

3

original This field stores the original or not yet processed “expression”. Its type is string.

tokenized This field stores the expression as a sequence of tokens. Its type is vector.

postfix This field stores the expression as a sequence of tokens in postfix nota- tion provided the expression has arithmetic type. Its type is vector. This member is not used for the current homework assignment but will be used for the last assignment. The set method or con- structors of this assignment should leave it as an empty vector, that is to do nothing.

valid This field indicates whether the expression is a valid expression (no syntax error). Its type is bool. It is not used for the current homework assignment but will be used for the last assignment. The set method or constructors of this assignment should simply set it to false.

type This field indicates whether the type of the expression is ASSIGNMENT or ARITHMETIC expression or ILLEGAL. Its type is Exp type. It is not used for the current homework assignment but will be used for the last assignment. The set method or constructors of this assignment should simply set it to ILLEGAL.

The member functions are:

Expression() This default constructor initializes all fields to empty or false or ILLEGAL.

Expression(const string& s) This constructor takes in a string and treats it as an expression. It tokenizes the input string and sets the original and tokenized members accordingly. And it sets the other members based on the description given earlier (refer to each member description).

void set(const string& s) This method takes in a string and treats it as an expression. It tokenizes the input string and sets the original and tok- enized members accordingly. And it sets the other members based on the description given earlier.

void display() const This method output the values of the expression fields, one field per line. This method is mainly for debugging use.

original=a12=1?ab + -a0123c(a+123)*(ab-(3+4 )) tokenized = a12;=;1?ab;+;-;a;0123;c;(;a;+;12;3;);*;(;ab;-;(;3;+;4;);); number of tokens = 24
postfix =

valid = false
type = ILLEGAL

4

string get original() const Getter for original member.

vector get tokenized() const Getter for tokenized member.

other methods There are other methods such as to evaluate the expression, to transform the expression, and getters for other fields such as postfix, valid, or type. These methods will be needed for the last assignment. Since we have not studied the related concepts and algorithms, these member functions are omitted.

When we receive a string (maybe from a line of input or a hard coded value within the program), which would be an expression, we use Expression class to figure out if the expression is legal or not and what its type is and so on (use either the non default constructor or set method, and pass the string as its argument).

In order to do the above, the string (perhaps a line of input from the user) gets tokenized first by the Expression class via its constructor or set method. That is perhaps the most challenging programming (algorithmic) task for the current implementation of the Expression class.

Since none of the member of the Expression class involves pointer type and memory allocation, the default copy constructor and assignment operator pro- vided by the compiler should work just fine. We do not need to implement them.

4 Implementation

Please note the similarity between the constructor that takes a string parameter and the set method in Token class. We could implement the set method first. Then the constructor calls the set method to accomplish its tasks. The same can be said for the similarity between the non default constructor and set method in Expression class.

You should implement and test the Token class first. Then use it in the development of the Expresion class. The most challenging method to implement (develop the code for) is the set method of the Expression class. We need to figure out the right algorithm to tokenize. One of the reasons is that we cannot simply use space (a blank character) as a delimiter to tokenize. For instance, in (2+3)*4, we have 7 valid tokens. They are (, 2, +, 3, ), *, 4 and no space betweenthem. Butifitisgivenas( 2 + 3 ) * 4,wecouldusespace. Our method should work for any possible combination of spaces and tokens. You might first assume space is used to separate each token including special tokens and develop a solution. Then consider if you might add space to the given string to use your with space as delimiter solution earlier. This approach is perhaps less efficient than those algorithms that process the string once because it processes a string twice and might double its length. However, it is acceptable for this assignment.

5

For those students who would like a challenge, you might develop an efficient algorithm that tokenizes the string with one pass through the given string.

Token class implementation has .h and .cpp files and the same is true for Expression class. The homework3.cpp file contains the code for testing of both classes.

5 Test and evaluation

Have a main program to test the Token class by sending the constructor and set method many different “tokens” and display the results to see if they are correct or not. You may want to be creative and cover a wide range of possible “tokens” in your testing. Similarly, test the Expression class by sending the constructor and set method many different “expressions” and display the results to see if they are correct or not. You may want to be creative and cover a wide range of possible “expressions” in your testing.

In: Computer Science

DO THIS IN C# (PSEUDOCODE)Social Security Payout. If you’re taking this course, chances are that you’re...

DO THIS IN C# (PSEUDOCODE)Social Security Payout. If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called Social Security. In simplest terms, it’s a way to pay into a system and receive money back when you retire (and the longer you work and the higher your salary, the higher your monthly benefit). Interestingly, your employer will pay the same amount for you. The current tax rate is 6.2% until you make approximately $132,900. For this assignment, we’re going to help out hourly employees. Design (pseudocode) and implement (source code) a program that asks users how much they make per hour, the number of hours they work per week, and calculates the yearly income. For the second half, the program should calculate and display the amount of Social Security tax the user will pay for that year. You must write and use at least two functions in addition to the main function. At least one function must not have a void return type. Note, don’t forget to put the keywords “public” and “static” in front of your functions. Document your code and properly label the input prompt and the outputs as shown below.

Sample run 1: Enter hourly wage: 10 Enter your hours per week: 40 You will earn $20800.0 per year You will pay $1591.2 in Social Security tax Sample run 2: Enter hourly wage: 40 Enter your hours per week: 60 You will earn $124800.0 per year You will pay $9547.2 in Social Security tax

In: Computer Science