Questions
This question need to be solved using java coading :- I. Input All input data are...

This question need to be solved using java coading :-

I. Input

   All input data are from a file "in.dat". The file contains a
sequence of infix form expressions, one per line. The character '$' 
is an end mark. For example, the following file has four infix form 
expressions:

   1 + 2 * 3 ^ ! ( 4 == 5 ) $
   3 * ( 6 - 4 * 5 + 1) + 2 ^ 2 ^ 3 $
   77 > ( 2 - 1 ) + 80 / 4 $
   ! ( 2 + 3 * 4 >= 10 % 6 ) && 20 != 30 || 45 / 5 == 3 * 3 $

Each expression is a sequence of tokens (i.e., constant integers,
operators, and end mark) separated by spaces. There is no variable.


II. Output

   Output data and related information are sent to the screen.
Your program should do the following for each expression:

   (1) printing the expression before it is manipulated;
   (2) showing the converted postfix form expression;
   (3) showing the expression tree;
   (4) printing the fully parenthesized infix form expression;
   (5) reporting the value of the expression.


III. Operators

   The following operators are considered. They are listed in the
decreasing order of precedence.

   Token            Operator            Associativity

    !               logical not         right-to-left
    ^               exponentiation      right-to-left
    *  /  %         multiplicative      left-to-right
    +  -            additive            left-to-right
    <  <=  >  >=    relational          left-to-right
    ==  !=          equality            left-to-right
    &&              logical and         left-to-right
    ||              logical or          left-to-right


IV. Other Requirements

   Since a large amount of information are to be displayed on the
screen, it is mandatory for your program to provide users a prompting
message such as

          Press <Enter> to continue ...

after each expression is processed, so that users have the chance to
check the output of your program carefully.


V. Algorithm: Infix_to_postfix conversion

  Input:  An infix form expression E = t1 t2 t3 ... $,
          which is a sequence of tokens.
  Output: The postfix form expression of E.

  Algorithm: 
  {
    do {
      get the next token t;
      case (t) {
         operand: place t onto the output;
                  break;
        operator: while (stack s is not empty
                    && stacktop(s) is not a left parenthesis)
                    && precedence(stacktop(s)) >= precedence(t)
                       // assuming left-to-right associativity, 
                       // not for the exponentiation operator ^, 
                       // which has right-to-left associativity 
                  {
                        pop(x,s);
                        place x onto the output;
                  }
                  push(t,s);
                  break;
               (: push(t,s);
                  break;
               ): while (stacktop(s) is not a left parenthesis) {
                      pop(x,s);
                      place x onto the output;
                  }
                  pop(x,s);
                  break;
        end mark: while (stack s is not empty) {
                      pop(x,s);
                      place x onto the output;
                  }
                  place the end mark onto the output;
                  break;
      }
    } while (t is not the end mark);
  }

This below is "in.dat file"

12 * 23 <= ( ( ( 3456 ) ) +    ( 6789 ) ) $ 1
4 ^ 3 - ( 2 + 4 * 15 ) - ( 90 / 3 != 30 ) $ 2
! ( 222 < 111 ) + 2 * 3 ^ ( 29 - 3 * 9 ) > 18 && 1234 == 1234 $ 1
( 2 * ( 62 % 5 ) ) ^ ( ( 4 - 2 ) ) - 2 ^ 2 ^ 2 $ 0
( ( 9 / ( 5 - 2 ) + 2 ) * ( 2 ^ 2 * 2 ) - 79 ) || ! ( 65432 > 54321 ) $ 1
( ( 9999 >= 8888 ) + 2 ) * ( 4 / ( 999 - 997 ) ) - 2 ^ ( 5 - 3 ) $ 2

In: Computer Science

Develop a C++ class called PrimeNumberGenerator. An object of this class will generate successive prime numbers...

Develop a C++ class called PrimeNumberGenerator. An object of this class will generate successive prime numbers on request. Think of the object as being similar to the digital tasbeeh counter. It has a reset button which makes the counter return to 0. There is also a button to get the next prime number. On the tasbeeh, pressing this button increments the current value of the counter. In your object, pressing this button would generate the next prime number for display. You’ll implement the reset button as a member function reset() and the other button as a function getNextPrime(). When an object is first created and the getNextPrime() function is called, it will return the first prime number, i.e., 2. Upon subsequent calls to the getNextPrime() function, the subsequent prime numbers will be returned. Define any others functions such as constructor and attributes that you need. According to Wikipedia: “a prime number is a natural number greater than 1, that has no positive divisors other than 1 and itself.”

In: Computer Science

Prove that the following language is context-free: L = { ω#x | ωR is a substring...

Prove that the following language is context-free: L = { ω#x | ωR is a substring of x and x, w ∈ {0,1}* } where ωR is ω reversed.

In: Computer Science

Make a program that calculates the total of a retail sale. The program should ask the...

Make a program that calculates the total of a retail sale. The program should ask the user for the following: the retail price of the item being purchased and the sales tax rate. Once the information has been entered, the program should calculate and display the following: the sales tax for the purchase and the total sale.

In: Computer Science

Write a menu-driven program to read 3 employees' information from a text file called “ EmployeeFile”...

Write a menu-driven program to read 3 employees' information from a text file called “ EmployeeFile” for this example but that can be edited to add more employees later.
Each employee has a name field, ID fields, and a Salary Record.
The Salary Record has weekly hours, rate per hour, gross salary, Tax, and net salary field.

1.1 Implement the project with queue using pointers

1.2 Write push and pop functions for queue using pointers

C++

EmployeeField.txt example


John_Doe 123456 40 45 4500 200 4300
Billy_Bob 654321 40 200 4000 200 3800
Kate_Johnson 531642 40 300 12000 200 11800

please make sure it works on free compilers online like https://repl.it/languages/cpp to be tested.

In: Computer Science

Program description is given below!! Client and Server Online Game Jumble: In this assignment, you need...

Program description is given below!!

Client and Server Online Game Jumble: In this assignment, you need to use socket programming to implement an online game Jumble. Generate a random work in server and send it to client and ask for input and then client send the guessed word to server and server check whether its in a word.txt file and reply Win or lose.

Note:

  • Reading content of a text file to a list and generating random number, and game logic is already implemented in jumble.py
  • ONLY need modification in echo-client.py and thread-server.py to implement socket programming.

Test your code and make sure the server can serve multiple players simultaneously. Note the words should be generated independently for each client, so that normally different clients are guessing different words

-----------------------Code--------------------

"""-----------------thread-server.py----------------------
Server side: open a socket on a port, listen for a message from a client,
and send an echo reply; echoes lines until eof when client closes socket;
spawns a thread to handle each client connection; threads share global
memory space with main thread; this is more portable than fork: threads
work on standard Windows systems, but process forks do not;
"""

import time, _thread as thread # or use threading.Thread().start()
from socket import * # get socket constructor and constants
myHost = '' # server machine, '' means local host
myPort = 50007 # listen on a non-reserved port number

sockobj = socket(AF_INET, SOCK_STREAM) # make a TCP socket object
sockobj.bind((myHost, myPort)) # bind it to server port number
sockobj.listen(5) # allow up to 5 pending connects

def now():
return time.ctime(time.time()) # current time on the server

def handleClient(connection): # in spawned thread: reply
time.sleep(5) # simulate a blocking activity
while True: # read, write a client socket
data = connection.recv(1024)
if not data: break
reply = 'Echo=>%s at %s' % (data, now())
connection.send(reply.encode())
connection.close()

def dispatcher(): # listen until process killed
while True: # wait for next connection,
connection, address = sockobj.accept() # pass to thread for service
print('Server connected by', address, end=' ')
print('at', now())
thread.start_new_thread(handleClient, (connection,))

dispatcher()

"""------------------echo-client.py-------------------------
Client side: use sockets to send data to the server, and print server's
reply to each message line; 'localhost' means that the server is running
on the same machine as the client, which lets us test client and server
on one machine; to test over the Internet, run a server on a remote
machine, and set serverHost or argv[1] to machine's domain name or IP addr;
Python sockets are a portable BSD socket interface, with object methods
for the standard socket calls available in the system's C library;
"""

import sys
from socket import * # portable socket interface plus constants
serverHost = 'localhost' # server name, or: 'starship.python.net'
serverPort = 50007 # non-reserved port used by the server

message = [b'Hello network world'] # default text to send to server
# requires bytes: b'' or str,encode()
if len(sys.argv) > 1:   
serverHost = sys.argv[1] # server from cmd line arg 1
if len(sys.argv) > 2: # text from cmd line args 2..n
message = (x.encode() for x in sys.argv[2:])

sockobj = socket(AF_INET, SOCK_STREAM) # make a TCP/IP socket object
sockobj.connect((serverHost, serverPort)) # connect to server machine + port

for line in message:
sockobj.send(line) # send line to server over socket
data = sockobj.recv(1024) # receive line from server: up to 1k
print('Client received:', data) # bytes are quoted, was `x`, repr(x)

sockobj.close() # close socket to send eof to server

--------------------------jumble.py----------------------

import random
F = open('wordlist.txt')
words = F.readlines()
F.close()
while True:
word = words[random.randrange(len(words))]
while len(word) > 5 or len(word) == 0:
word = words[random.randrange(0, len(words))]
word = word.rstrip()
old_word = word
word = list(word)
while word:
print(word.pop(random.randrange(len(word))), end = ' ')
print('\nType your answer')
match_word = input()
new_word = match_word + '\n'
if new_word in words and set(match_word) == set(old_word):
print('You win.')
else:
print('The answer is ' + old_word)

-------------------wordlist.txt---------------------

ab
aba
abaca
abacist
aback
abactinal
abacus
abaddon
abaft
abalienate
abalienation
abalone
abampere
abandon
abandoned
abandonment
abarticulation
abase
abased
abasement
abash
abashed
abashment
abasia
abasic
abate
abatement
abating
abatis
abatjour
abattis
abattoir
abaxial
abba

------------------------------------------------

Thank in advance! Please help me soon. I will UPVOTE!!

In: Computer Science

Consider a B-tree allowing splits and free-on-empty. Please show an example of these operations on a...

Consider a B-tree allowing splits and free-on-empty. Please show an example of these operations on a data structure containing 15 data items, a fanout of three, and at most three data items per node. Also give the search algorithm (use a give-up scheme).

In: Computer Science

The ReservedRoom Class: Each ReservedRoom entry has three (data) fields: roomID (string) of the classroom e.g....

  1. The ReservedRoom Class:

Each ReservedRoom entry has three (data) fields:

  • roomID (string) of the classroom e.g. W330, W350, W361, etc.
  • courseID (string) which stores which course reserves this room
  • time (int): which stores the start time of the reserved slot i.e. 1820 means the reservation starts at 18:20

Thus, the ReservedRoom class will consist of three data members (roomID and courseID, time), in addition to the associated methods needed as follows.

  1. The constructor ReservedRoom (r, c, t): constructs a ReservedRoom object with the given parameters.
  2. String getRoom(): returns the roomID field.
  3. String getCourse(): returns the courseID field.
  4. int getTime(): returns the time field.
  5. String toString(): returns a String representation of this ReservedRoom entry.

Implement the ReservedRoom ADT using Java programming language.

The RoomsBoard Class:

RoomsBoard is a singly-linked list of ReservedRoom. The class RoomsBoard supports the following operations:

  1. void add(ReservedRoom r): adds a new ReservedRoom object to RoomsBoard. The ReservedRoom object should be inserted into the RoomsBoard list such that the nodes of the list appear in non-decreasing order of time.
  2. void remove(String roomID): removes all occurrences of the room with this ID.
  3. void remove_all_but(String roomID): removes all the reserved rooms except the room with this ID.
  4. void removeAll(): clears the RoomsBoard by removing all rooms entries.
  5. void split( RoomsBoard board1, RoomsBoard board2): splits the list into two lists, board1 stores the list of reserved rooms before 12:00 and board2 stores the list of rooms after 12:00.
  6. void listRooms(): prints a list of the reserved rooms in the roomsboard, in non-decreasing order.
  7. Void listReservations( roomID): prints the list of reservations for this room in the roomsboard, in non-decreasing order.
  8. int size(): returns the number of reserved rooms stored in the roomsboard.
  9. boolean isEmpty(): returns true if the RoomsBoard object is empty and false otherwise.

Implement the RoomsBoard ADT with a singly-linked list using Java programming language. The implementation must utilize the generic class Node as described in Section 3.2.1 of your text. Figure 1 shows a sample RoomsBoard object.

  1. The Menu-driven Program:

Write a menu-driven program to implement a roomsboard for a classroom reservations system. The menu includes the following options:

  1. Add new room.
    The program will prompt the user to enter the roomID, courseID and time of the new reserved room, then will call the add() method from the RoomsBoard class.
  2. Remove all occurrences of a room.
    The program will prompt the user to input the room ID to be removed, then call the remove() method from the RoomsBoard class.
  3. Remove all rooms except a room.
    The program will prompt the user to input the room ID to be kept, then call the remove_all_but () method from the RoomsBoard class.
  4. Clear the RoomsBoard.

The program will call the removeAll() method from the RoomsBoard class.

  1. Split the list of rooms into two lists by calling the method split() from the RoomsBoard class.
  2. Display RoomsBoard.
    The program will call the listRooms() method from the RoomsBoard class.
  3. Display the reservations of a room.
    The program will call the listReservations() method from the RoomsBoard class to display all reservations of this room with the given roomID.
  4. Exit.

The program should handle special cases and incorrect input, and terminate safely. Examples include (but not limited to) the following:

  1. Removing a RoomsEntry object from an empty RoomsBoard object.
  2. Removing a ReservedRoom object with a roomID that is not in the RoomsBoard object.
  3. Displaying an empty RoomsBoard object.
  4. Entering an incorrect menu option.

In: Computer Science

What kind of network management protocols are available? What information can these protocols provide? Explain it...

What kind of network management protocols are available? What information can these protocols provide? Explain it with example.

In: Computer Science

What is path sensitization? Why do we do it or why it is important, explain with...

What is path sensitization? Why do we do it or why it is important, explain with an example?

In: Computer Science

Write a void function that will display the statement “Emancipation of women in Ghana was led...

Write a void function that will display the statement “Emancipation of women in Ghana was led by Nana Agyeman Rawlings “.

In: Computer Science

ONLY looking for part B!! a. Using C++, define a node structure of the linked list...

ONLY looking for part B!! a. Using C++, define a node structure of the linked list (e.g. value is an integer, next is a node type pointer), construct a linked list of 10 nodes and assign random numbers as the nodes’ values. Use loop to track and print from the first node to the last and output all nodes’ values. Finally, free all memories of the linked list. b. Based on 2.a, (1) define a function which takes the header as parameter, the function will create a new node and assign its value 100; then insert this node at the sixth position of the list; (2) define another function which recursively print the list forwards to verify the result; (3) define the 3rd function which takes the header as parameter, the function will delete the eighth node of the list to keep the linked list having 10 nodes, and (4) define the 4th function which recursively to print the linked list backwards. After creating the four functions, revise your program 2.a, before delete all memories of the list, call the four functions in order to verify the results.

In: Computer Science

in C++, #include<iostream> using namespace std; const int NUM = 10; void prepareArr(int a[]); int countEven...

in C++,

#include<iostream>

using namespace std;

const int NUM = 10;

void prepareArr(int a[]);

int countEven (int b[]);

int main() {

int arr[NUM];

// write a statement to call prepareArr to set values for the array


// write a statement to call countEven and print the data returned



for(int i = 0; i<NUM; i++)

cout << arr[i] <<" ";

cout <<endl;

return 0;

}

void prepareArr(int a[])

{

//randomly generate NUM integers in the range [0,99] and save them in the array parameter.

}

int countEven (int b[])

{

//count the number of even integers in the array parameter and return the number, note that the size of the array is specified with NUM.

}

Previous

In: Computer Science

Analyze the cost data below for the Costbusters Company. Graph the percent of quality costs by...

Analyze the cost data below for the Costbusters Company.

  1. Graph the percent of quality costs by product?

  2. What are the dollar costs for each cost of quality category, by product? Graph

  3. How might this information be used to help define a Six Sigma project?

    PRODUCT A PRODUCT B PRODUCT C
    Total Sales
    Total quality cost as a percent of sales 24% 19% 15%
    External Failure 35% 22% 8%
    Internal Failure 52% 29% 24%
    Appraisal 10% 38% 38%
    Prevention 3% 11% 30%

    Can this problem be solved in minitab with graphs or Excel showing each steps? This is for my lean six sigma class

In: Computer Science

Objective: Upon completion of this program, you should gain experience with overloading basic operators for use...

Objective: Upon completion of this program, you should gain experience with overloading basic operators for use with a C++ class.

The code for this assignment should be portable -- make sure you test with g++ on linprog.cs.fsu.edu before you submit.

Task

Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). The class, along with the required operator overloads, should be written in the files "mixed.h" and "mixed.cpp".

Details and Requirements

  1. Your class must allow for storage of rational numbers in a mixed number format. Remember that a mixed number consists of an integer part and a fraction part (like 3 1/2 -- "three and one-half"). The Mixed class must allow for both positive and negative mixed number values. A zero in the denominator of the fraction part constitutes an illegal number and should not be allowed. You should create appropriate member data in your class. All member data must be private.
  2. There should be two constructors. One constructor should take in three parameters, representing the integer part, the numerator, and the denominator (in that order), used to initialize the object. If the mixed number is to be a negative number, the negative should be passed on the first non-zero parameter, but on no others. If the data passed in is invalid (negatives not fitting the rule, or 0 denominator), then simply set the object to represent the value 0. Examples of declarations of objects:
     Mixed m1(3, 4, 5);    // sets object to 3 4/5 
     Mixed m2(-4, 1, 2);   // sets object to -4 1/2 
     Mixed m3(0, -3, 5);   // sets object to -3/5 (integer part is 0). 
     Mixed m4(-1, -2, 4);  // bad parameter combination.  Set object to 0. 
    

    The other constructor should expect a single int parameter with a default value of 0 (so that it also acts as a default constructor). This constructor allows an integer to be passed in and represented as a Mixed object. This means that there is no fractional part. Example declarations:

     Mixed m5(4);  // sets object to 4 (i.e. 4 and no fractional part). 
     Mixed m6;     // sets object to 0 (default)
    
    Note that this last constructor will act as a "conversion constructor", allowing automatic type conversions from type int to type Mixed.
  3. The Mixed class should have public member functions Evaluate(), ToFraction(), and Simplify(). The Evaluate() function should return a double, the others don't return anything. These functions have no parameters. The names must match the ones here exactly. They should do the following:
    • The Evaluate function should return the decimal equivalent of the mixed number.
    • The Simplify function should simplify the mixed number representation to lowest terms. This means that the fraction part should be reduced to lowest terms, and the fraction part should not be an improper fraction (i.e. disregarding any negative signs, the numerator is smaller than the denominator).
    • The ToFraction function should convert the mixed number into fraction form. (This means that the integer part is zero, and the fraction portion may be an improper fraction).
  4. Create an overload of the extraction operator >> for reading mixed numbers from an input stream. The input format for a Mixed number object will be:
     integer numerator/denominator 
    

    i.e. the integer part, a space, and the fraction part (in numerator/denominator form), where the integer, numerator, and denominator parts are all of type int. You may assume that this will always be the format that is entered (i.e. your function does not have to handle entry of incorrect types that would violate this format). However, this function should check the values that come in. In the case of an incorrect entry, just set the Mixed object to represent the number 0, as a default. An incorrect entry occurs if a denominator value of 0 is entered, or if an improper placement of a negative sign is used. Valid entry of a negative number should follow this rule -- if the integer part is non-zero, the negative sign is entered on the integer part; if the integer part is 0, the negative sign is entered on the numerator part (and therefore the negative sign should never be in the denominator). Examples:

     Valid inputs:     2 7/3 , -5 2/7  , 4 0/7  , 0 2/5  , 0 -8/3 
     Invalid inputs:   2 4/0 , -2 -4/5 , 3 -6/3 , 0 2/-3 
    
  5. Create an overload of the insertion operator << for output of Mixed numbers. This should output the mixed number in the same format as above, with the following exceptions: If the object represents a 0, then just display a 0. Otherwise: If the integer part is 0, do not display it. If the fraction part equals 0, do not display it. For negative numbers, the minus sign is always displayed to the left.
     Examples:   0  ,  2  ,  -5  ,  3/4  ,  -6/7  ,  -2 4/5  ,  7 2/3 
    
  6. Create overloads for all 6 of the comparison operators ( < , > , <= , >= , == , != ). Each of these operations should test two objects of type Mixed and return an indication of true or false. You are testing the Mixed numbers for order and/or equality based on the usual meaning of order and equality for numbers. (These functions should not do comparisons by converting the Mixed numbers to decimals -- this could produce round-off errors and may not be completely accurate).
  7. Create operator overloads for the 4 standard arithmetic operations ( + , - , * , / ) , to perform addition, subtraction, multiplication, and division of two mixed numbers. Each of these operators will perform its task on two Mixed objects as operands and will return a Mixed object as a result - using the usual meaning of arithmetic operations on rational numbers. Also, each of these operators should return their result in simplified form. (e.g. return 3 2/3 instead of 3 10/15, for example).
    • In the division operator, if the second operand is 0, this would yield an invalid result. Since we have to return something from the operator, return 0 as a default (even though there is no valid answer in this case). Example:
      Mixed m(1, 2, 3);               // value is 1 2/3
      Mixed z;                        // value is 0
      Mixed r = m / z;                // r is 0 (even though this is not good math)
      
  8. Create overloads for the increment and decrement operators (++ and --). You need to handle both the pre- and post- forms (pre-increment, post-increment, pre-decrement, post-decrement). These operators should have their usual meaning -- increment will add 1 to the Mixed value, decrement will subtract 1. Since this operation involves arithmetic, leave incremented (or decremented) object in simplified form (to be consistent with other arithmetic operations). Example:
      Mixed m1(1, 2, 3);            //  1 2/3
      Mixed m2(2, 1, 2);            //  2 1/2
      cout << m1++;                   //  prints 1 2/3, m1 is now 2 2/3
      cout << ++m1;                   //  prints 3 2/3, m1 is now 3 2/3
      cout << m2--;                   //  prints 2 1/2, m2 is now 1 1/2
      cout << --m2;                   //  prints 1/2  , m2 is now 0 1/2
    
  9. General Requirements
    • As usual, no global variables
    • All member data of the Mixed class must be private
    • Use the const qualifier whenever appropriate
    • The only libraries that may be used in the class files are iostream and iomanip
    • Do not use langauge or library features that are C++11-only
    • Since the only output involved with your class will be in the << overload (and commands to invoke it will come from some main program or other module), your output should match mine exactly when running test programs.

In: Computer Science