Questions
Write a python code using a continuous random variable and using uniform distribution to output the...

Write a python code using a continuous random variable and using uniform distribution to output the expected weight of students in a class.

In: Computer Science

Construct a finite-state machine, using combinational logic, which reads in one bit at a time. When...

  1. Construct a finite-state machine, using combinational logic, which reads in one bit at a time. When a nibble (4 bits) are all zeros the output is set to one else the output is zero. The machine continues to read in bits and the output remains a one if zeros are read in. If it reads a one the output is a zero.
    1. What are the machine states?
    2. What are the inputs?
    3. What are the outputs?
    4. Draw state table.
    5. Draw the state diagram.
    6. Define the circuit for the next state and the output with the Boolean equations.
    7. Explain if you built a Mealy or Moore machine.

In: Computer Science

This is JAVA PROGRAMMING Sort the contents of the two files in ascending order and combine...

This is JAVA PROGRAMMING

Sort the contents of the two files in ascending order and combine them into one new file (words.txt).
When comparing string order, you must use the compareTo method and make an exception.The source code below is a code that only combines files. Use the comparedTo method to sort the contents of the two files in ascending order.(ex. if(str1.compareTo(str2)<0) {})

<file1.txt>

at first  
castle  
consider  
considerable  
enlighten  
explain  
explanation  
female  

<file2.txt>

consideration  
considering that  
education  
educational  
endow  
inherit  

<code>

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Lab7_1 {

   public static void main(String[] args) {
       // TODO Auto-generated method stub
      
       fileMerge("file1.txt","file2.txt","words.txt");
   }
   private static void fileMerge(String filename1, String filename2, String filename3) {
       // TODO Auto-generated method stub
       Scanner str1=null;
       Scanner str2=null;
       PrintWriter output=null;
      
       try {
           str1 = new Scanner(new File(filename1));
               str2 = new Scanner(new File(filename2));
               output = new PrintWriter(new File(filename3));
              
               fileWriter(str1,output);
               fileWriter(str2,output);
              
          
      
       } catch (FileNotFoundException e) {
           // TODO Auto-generated catch block
           System.err.println(e.getMessage());
           // e.printStackTrace();
      
       } finally {
           if (str1 != null)
               str1.close();
           if (str2 != null)
               str2.close();
           if (output != null)
               output.close();

       }
   }
       private static void fileWriter(Scanner str1, PrintWriter output) {
           // TODO Auto-generated method stub
           while(str1.hasNextLine()) {
               String str = str1.nextLine();
               output.println(str);
       }

   }

          
   }

In: Computer Science

A new implementation of Merge Sort uses a cutoff variable to use insertion sort for small...

A new implementation of Merge Sort uses a cutoff variable to use insertion sort for small number of items to be merged (Merging single elements is costly).

1. Give the pseudo code for the merge sort algorithm with a cutoff variable set to 4.

2. Show the trace for top-down merge sort using the following array of characters with a cutoff variable set to 4.

E A S Y M E R G E S O R T W I T H I N S E R T I O N

In: Computer Science

Program a math quiz on Python Specifications: - The program should ask the user a question...

Program a math quiz on Python

Specifications:

- The program should ask the user a question and allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed.

- the program should use three functions, one function to generate addition questions, one for subtraction questions, and one for multiplication questions.

- the program should store the questions and answers in a dictionary or list.

- the program should keep a count of the number of correct and incorrect responses.

In: Computer Science

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