Questions
Done in C language using mobaxterm if you can but use basic C This program is...

Done in C language using mobaxterm if you can but use basic C

This program is broken up into three different functions of insert, delete, and main. This program implements a queue of individual characters in a circular list using only a single pointer to the circular list; separate pointers to the front and rear elements of the queue are not used.

  1. The linked list must be circular.  
      
  2. The insert and remove operations must both be O(1)
      
  3. You may use only one pointer into the queue from the outside; you may not have separate, named pointers for the front and the rear.

Test Cases:

  1. Try to remove – thus making sure that the queue was initialized properly (i.e., empty)
  2. Insert 'A', then do a remove, then another remove – thus making sure that you can empty the queue
  3. Insert 'B', then 'F', do a remove, then insert 'D', then 'C', then do four removes (the last one should fail, of course). This test case will make sure your queue is FIFO – your last four removes should come out 'F', 'D', 'C', and then "cannot remove from an empty queue"

In: Computer Science

Invoice Class - Create a class called Invoice that a hardware store might use to represent...

Invoice Class - Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables—a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double).

  • Your class should have a constructor that initializes the four instance variables. If the quantity passed to the constructor is not positive, it should be set to 0 by the constructor. If the price per item passed to the constructor is not positive, it should be set to 0.0 by the constructor.

  • Provide a set and a get method for each instance variable. If the quantity passed to the setQuantity method is not positive, it should be set to 0 by the method. If the price per item passed to the setPricePerItem method is not positive, it should be set to 0.0 by the method.

  • Provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value.

Write a test app named InvoiceTest that demonstrates class Invoice’s capabilities. Create two Invoice objects, print their state, and invoice amounts.

(Java Programming)

In: Computer Science

What are some of the Organizing Activities within a Project?

What are some of the Organizing Activities within a Project?

In: Computer Science

please write simple python code Write a program to replicate the behavior of UNIX utility “tail”....

please write simple python code

Write a program to replicate the behavior of UNIX utility “tail”. It takes one or more files and displays requested number of lines from the ending. If number is not specified, then it print 10 lines by default.

In: Computer Science

What are the uses of DBMS and its benefits?

What are the uses of DBMS and its benefits?

In: Computer Science

How would you compare MySQL, MSSQL, Oracle, SQLite based on current version, operating system, cost, written...

How would you compare MySQL, MSSQL, Oracle, SQLite based on current version, operating system, cost, written in, licensing, graphical management tools, and maximum number of records?

In: Computer Science

JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO...

JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO YOU I NEED YOUR HELP PLEASE HELP ME. I WILL GIVE UPVOTE AND GOOD COMMENT THANK YOU SO MUCH !!!

QUESTION 1

  1. Consider the following program segment:

    int i = 2;
    int n = 18;

    while (i < n)
    {
        if ((i % 2) == 0)
    i++;
    else
    n--;
    }
    System.out.println( i );

    What is the value of n when the above program segment is done executing?

    A.

    n is: 18.

    B.

    n is: 3.

    C.

    Infinite Loop. i will not change.

    D.

    No Output.

QUESTION 2

  1. Consider the following program segment:

    int i = 2;
    int n = 18;

    while (i < n)
    {
        if ((i % 2) == 0)
    i++;
    else
    n--;
    }
    System.out.println( i );

    What is the output of the above program segment?

    A.

    There is no output.

    B.

    The output is 2.

    C.

    The output is 18.

    D.

    The output is 3.

QUESTION 3

  1. Consider the following program segment:

    int i = 1;
    int n = 10;

    while (i < n)
    {
        if ((i % 2) != 0)
    i++;
    }
    System.out.println ( i );

    And what are the values of i and n after execution?

    A.

    i will be 11. n will be 10.

    B.

    i will be 11. n will be 1.

    C.

    Infinite Loop: i is stuck at 2 and n stays at 10.

    D.

    No Output

QUESTION 4

  1. Consider the following section of code:

    int i = 1;
    int j = 3;
    while (i < 15 && j < 20)
    {
    i++;
    j += 2;
    }
    System.out.println (i + j);

    And what are the values of i and j after execution?

    A.

    i = 10, j = 21

    B.

    i = 11, j = 22

    C.

    i = 15, j = 20

    D.

    i = 16, j = 21

QUESTION 5

  1. Consider the following section of code:

    int i = 1;
    int j = 3;
    while (i < 15 && j < 20)
    {
    i++;
    j += 2;
    }
    System.out.println (i + j);

    What is the output of the above program segment?

    A.

    The output will be 31.

    B.

    The output will be 33.

    C.

    The output will be 34.

    D.

    The output will be 35.

QUESTION 6

  1. Consider the following section of code:

    int x = 10;
    do
    {
       System.out.println( x );
    x -= 3;
    }
    while (x > 0);

    And what is the value of x after execution?

    A.

    The value of x after loop is done = -1.

    B.

    The value of x after loop is done = -2.

    C.

    The value of x after loop is done = 1.

    D.

    The value of x after loop is done = 2.

QUESTION 7

  1. Consider the following section of code:

    int x = 10;
    do
    {
       System.out.println( x );
    x -= 3;
    }
    while (x > 0);

    What is the output of the following program segment?

    A.

    -2

    B.

    10 9 8 7 6 5 4 3 2 1

    C.

    1 4 7 10

    D.

    10

    7

    4

    1

QUESTION 8

  1. Consider the following section of code:

    int i = 1;
    int n = 0;
    while (i <= n)
    {
    System.out.print( i );
    i++;
    }

    And what are the values of i and n after execution?

    A.

    i = 1 and n = 0.

    B.

    i = 2 and n = 0.

    C.

    i = 0 and n = 0.

    D.

    i = -1 and n = 0.

QUESTION 9

  1. Consider the following section of code:

    int i = 1;
    int n = 0;
    while (i <= n)
    {
    System.out.print( i );
    i++;
    }

    What is the output of the following program segment?

    A.

    1, 2, 3, ...

    B.

    1

    C.

    0

    D.

    No output.

In: Computer Science

What is the difference between a bitmap image and a vector image? In terms of processing...

What is the difference between a bitmap image and a vector image? In terms of processing speed, which is going to be a better image format? When would the other format be better to use?

Why should you use the PNG format instead of GIF? What are HEIC and HEVC formats and what are the advantages and disadvantages of them?

What does it mean for a compressed image to have artifacts? How do you ensure your photos and images never look poor quality like they were recorded with a potato?

In: Computer Science

For python! You walk into a fast food restaurant and order fries, a burger, and a...

For python!

You walk into a fast food restaurant and order fries, a burger, and a drink. Create a simple text based user interactive program keeps track of the menu items you order. Use a dictionary to keep track of your menu items and price and another dictionary to keep track of your order and quantity.

 Fries are $3.50

 Burger are $5.00

 Drinks are $1.00

 Sales tax rate is 7.25%

menu = { "burger":5.00, "fries":3.50, "drink":1.00 }

order = { "burger":0, "fries":0, "drink":0 }

i. Use menu for the menu items and price. Use order to keep a running total of the number of items ordered.

ii. Keep a running subtotal.

iii. When all items are ordered, calculate the sales tax and total amount.

iv. Print a simple receipt.

v. See the assignment description for a sample video of how this might function.

In: Computer Science

Language:c++ choice b and c dont display the file rearranged why is that and how can...

Language:c++

choice b and c dont display the file rearranged why is that and how can i fix it?

#include<iostream>
#include <fstream>
using namespace std;
#define size 10000

// Displays the current Inventory Data
void Display(int box_nums[], int nboxes[], double ppBox[], int n) // Prints Box number , number of boxes and price per box.
{
   cout << "Box number Number of boxes in stock Price per box" << "\n";
   cout << "-------------------------------------------------------------\n";
   for (int i = 0; i < n; i++)
   {
       cout << box_nums[i] << " " << nboxes[i] << " " << ppBox[i] << "\n";
   }
}

// sort's the inventory data according to the price per box from low to high
void sortByPrice(int box_nums[], int nboxes[], double priceBox[], int n)
{
   int i, j, min_idx, temp2;
   double temp;
   for (i = 0; i < n - 1; i++)
   {
       min_idx = i; // min_idx is used to store data in ascending order
       for (j = i + 1; j < n; j++) // used selection sort to sort the data based on price per box
       {
           if (priceBox[j] < priceBox[min_idx])
               min_idx = j;
       }
       temp = priceBox[min_idx];
       priceBox[min_idx] = priceBox[i]; // temp is a variable to swap data
       priceBox[i] = temp;

       temp2 = nboxes[min_idx];
       nboxes[min_idx] = nboxes[i]; // temp2 is a variable to swap data
       nboxes[i] = temp2;

       temp2 = box_nums[min_idx];
       box_nums[min_idx] = box_nums[i];
       box_nums[i] = temp2;

   }
}

// sort's the inventory data according to Box number from low to high
void sortByBoxNumber(int box_nums[], int nboxes[], double priceBox[], int n)
{
   int i, j, min_idx, temp2;
   double temp;
   for (i = 0; i < n - 1; i++)
   {
       min_idx = i; // min_idx is used to store data in ascending order
       for (j = i + 1; j < n; j++)
       {
           if (box_nums[j] < box_nums[min_idx]) // used selection sort to sort the data based on price per box
               min_idx = j;
       }

       temp2 = box_nums[min_idx];
       box_nums[min_idx] = box_nums[i];
       box_nums[i] = temp2;

       temp = priceBox[min_idx];
       priceBox[min_idx] = priceBox[i];
       priceBox[i] = temp;

       temp2 = nboxes[min_idx];
       nboxes[min_idx] = nboxes[i];
       nboxes[i] = temp2;
   }
}

// Searches for the price per box of the corresponding box number entered by user.
double lookUpByBoxNumber(int boxNumber, int box_nums[], double priceBox[], int n)
{
   int low = 0, high = n - 1;
   int mid;
   while (low <= high) // used binary search to search for the corresponding box number and its price-per-box
   {
       mid = low + (high - low) / 2;

       if (box_nums[mid] > boxNumber)
       {
           high = mid - 1;
       }
       else if (box_nums[mid] == boxNumber)
       {
           return priceBox[mid];
       }
       else
       {
           low = mid + 1;
       }

   }
   return -1;
}

//Reordered the data whose number of boxes are less than 100
void reorderReport(int box_nums[], int nboxes[], int n)
{
   int* reorderBoxNums = new int[n];
   int* reorderBoxes = new int[n];
   int k = 0;
   for (int i = 0; i < n; i++)
   {
       if (nboxes[i] < 100)
       {
           reorderBoxNums[k] = box_nums[i];
           reorderBoxes[k] = nboxes[i];
           k++;
       }
   }
   int i, j, max_idx, temp2;
   for (i = 0; i < k - 1; i++) // sorts the data in reordered data according to number of boxes in inventory from low to high
   {
       max_idx = i;
       for (j = i + 1; j < k; j++)
       {
           if (reorderBoxes[j] > reorderBoxes[max_idx])
               max_idx = j;
       }

       temp2 = reorderBoxes[max_idx];
       reorderBoxes[max_idx] = reorderBoxes[i];
       reorderBoxes[i] = temp2;

       temp2 = reorderBoxNums[max_idx];
       reorderBoxNums[max_idx] = reorderBoxNums[i];
       reorderBoxNums[i] = temp2;
   }
   cout << "REORDERED REPORT IS: \n";
   cout << "The boxes in invetory whose stock are less than 100 are: \n";
   cout << "Box number Number of boxes in stock" << "\n";
   cout << "------------------------------------------" << "\n";
   for (int i = 0; i < k; i++)
   {
       cout << reorderBoxNums[i] << " " << reorderBoxes[i] << "\n";
   }
}
int main()
{

   std::fstream myfile("inventory.txt");
   int box_number[size], numberOfBoxes[size];
   double pricePerBox[size], sp;
   int bn, nb, i = 0;
   while (myfile >> bn >> nb >> sp) // fetch data from file inventory.txt
   {
       box_number[i] = bn;
       numberOfBoxes[i] = nb;
       pricePerBox[i] = sp;
       i++;
   }

   int n = i, bnumber; // n stores number of records in file , bnumber is the box number which is to be searched for price-per-box by user
   double val; // val is variable used for value stored from lookup by box-number
   char option;
   bool exit = true; // exit variable to exit the while loop

   // Menu for the user
   cout << "\nChoose a option in the Menu a/b/c/d/e/f :" << "\n";
   cout << "a. Display the data" << "\n";
   cout << "b. Sort data by price, low to high" << "\n";
   cout << "c. Sort data by box number, low to high" << "\n";
   cout << "d. Look up the Price of the box given the box number" << "\n";
   cout << "e. Generate Reorder Report" << "\n";
   cout << "f. Exit" << "\n";

   while (exit)
   {
       cout << "Enter your choice a/b/c/d/e/f : ";
       cin >> option;

       switch (option)
       {
       case 'a':
           Display(box_number, numberOfBoxes, pricePerBox, n);
           break;
       case 'b':
           sortByPrice(box_number, numberOfBoxes, pricePerBox, n);
           cout << "Data has been Successfully sorted by price" << "\n";
           cout << "Please, choose option 'a' to display sorted data" << "\n";
           break;
       case 'c':
           sortByBoxNumber(box_number, numberOfBoxes, pricePerBox, n);
           cout << "Data has been Successfully sorted by Box Number" << "\n";
           cout << "Please, choose option 'a' to display sorted data" << "\n";
           break;
       case 'd':
           sortByBoxNumber(box_number, numberOfBoxes, pricePerBox, n);
           cout << "Enter the box number for which you want to search the price : ";
           cin >> bnumber;
           val = lookUpByBoxNumber(bnumber, box_number, pricePerBox, n);
           if (val < 0)
           {
               cout << "There is no price of the box for the box number you are searching for\n";
           }
           else
           {
               cout << "The price-per-box of the Box-Number you searched is " << val << "\n";
           }
           break;
       case 'e':
           reorderReport(box_number, numberOfBoxes, n);
           break;
       case 'f':
           exit = false;
           break;
       default:
           cout << "Invalid options , enter a valid option" << "\n";
           break;

       }

   }
   return 0;
}

In: Computer Science

In Python Write a function to read a Sudoku board from an input string. The input...

In Python

Write a function to read a Sudoku board from an input string.

The input string must be exactly 81 characters long (plus the

terminating null that marks the end of the string) and contains

digits and dots (the `.` character represents an unmarked position).

The input contains all 9 rows packed together. For example, a Sudoku

board that looks like this:

```

..7 ... ...

6.4 ... ..3

... .54 ..2

... .4. ...

9.. ... ..5

385 ..2 ...

... ..3 78.

49. 71. ...

1.. ..8 9..

```

would be input as the string

```

"..7......6.4.....3....54..2....4....9.......5385..2........378.49.71....1....89.."

```

The function must read the board into an array of 81 bytes, with the

value 0 (*not* the digit `'0'`) for unfilled positions (represented

by dots in the input) and the values 1 through 9 (*not* the digits

`'1'` through `'9'`) for filled positions.

As it reads, the function should validate the input. If it is too

short, it should return 1. If it encounters an invalid character

(not a dot or a digit) then it should return 2. If the string is too

long it should return 3.

The following pseudocode should form the basis of your function:

In: Computer Science

In the game of Lucky Sevens, the player rolls a pair of dice. If the dots...

In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are many ways to win: (1, 6), (2, 5), and soon. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many people's eyes glaze over at the first mention of mathematics “wins $4”.

      Your challenge is to write a program that demonstrates the futility of playing the game. Your Python program should take as input the amount of money that the player wants to put into the pot, and play the game until the pot is empty.

            The program should have at least TWO functions (Input validation and Sum of the dots of user’s two dice). Like the program 1, your code should be user-friendly and able to handle all possible user input. The game should be able to allow a user to ply as many times as she/he wants.

            The program should print a table as following:

      Number of rolls             Win or Loss                Current value of the pot

                              1                                 Put                                   $10

                    2                                           Win                                  $14

                    3                                           Loss                                 $11

                              4

                              ##                              Loss                                 $0

        You lost your money after ## rolls of play.

        The maximum amount of money in the pot during the playing is $##.

        Do you want to play again?

      At that point the player’s pot is empty (the Current value of the pot is zero), the program should display the number of rolls it took to break the player, as well as maximum amount of money in the pot during the playing.

        Again, add good comments to your program.

        Test your program with $5, $10 and $20.

In: Computer Science

in java Write an interface for a CD player. It should have the standard operations (i.e....

in java Write an interface for a CD player. It should have the standard operations (i.e. play, stop, nextTrack, previousTrack, etc.) that usual CD players have.

In: Computer Science

- True to its name, computer networking technologies allow computers of many kinds to be connected...

- True to its name, computer networking technologies allow computers of many kinds to be connected to each other and to human users. What are some of the ways that computer networking (not just computers) has impacted business, government and society?

- What is the purpose of the OSI model?

- Why is layering in the model is important and what purpose does it achieve?

- How is the OSI model different from the TCP/IP model and which layers of the OSI model are subsumed into the application layer of the TCP/IP model?

In: Computer Science

--- TURN this Code into Java Language --- #include <iostream> #include <string> using namespace std; //...

--- TURN this Code into Java Language ---

#include <iostream>
#include <string>

using namespace std;

// constants
const int FINAL_POSITION = 43;
const int INITIAL_POSITION = -1;

const int NUM_PLAYERS = 2;
const string BLUE = "BLUE";
const string GREEN = "GREEN";
const string ORANGE = "ORANGE";
const string PURPLE = "PURPLE";
const string RED = "RED";
const string YELLOW = "YELLOW";
const string COLORS [] = {BLUE, GREEN, ORANGE, PURPLE, RED, YELLOW};
const int NUM_COLORS = 6;

// names of special characters marking specific spaces on the board
const string PLUMPY = "PLUMPY";
const string MR_MINT = "MR. MINT";
const string JOLLY = "JOLLY";

// A partial board for Candyland
// based on the picture at: http://www.lscheffer.com/CandyLand-big.jpg
string board[] = {RED, PURPLE, YELLOW, BLUE, ORANGE, GREEN, RED, PURPLE, PLUMPY, YELLOW,
                  BLUE, ORANGE, GREEN, RED, PURPLE, YELLOW, BLUE, MR_MINT, ORANGE, GREEN,
                  RED, PURPLE, YELLOW, BLUE, ORANGE, GREEN, RED, PURPLE, YELLOW, BLUE,
                  ORANGE, GREEN, RED, PURPLE, YELLOW, BLUE, ORANGE, GREEN, RED, PURPLE,
                  YELLOW, BLUE, JOLLY, ORANGE
                  
               };

int positions[NUM_PLAYERS];

// set all elements of the positions array to INITIAL_POSITION
// Parameters: positions -- will store where the players are
//             numPlayers -- how many there are
void initialize(int positions[], int numPlayers) {
    for (int player = 0; player < numPlayers; player++)
        positions[player] = INITIAL_POSITION;
}

// Description: Test if string is a valid color in the game
// Parameter: str -- string to test
// Returns: true if it is a color in the game, false if not
bool isColor(string str) {
     for (int color = 0; color < NUM_COLORS; color++) {
         if (str == COLORS[color])
             return true;
     }
     return false;
}

// Description: Starting after indicated position search forward on board to find the color
// Parameters: startPos -- index of current space of player -- start looking *after* this space
//             color -- find the next space with this color
// Returns: index of next space of chosen color
int findColor(int startPos, string color) {
    for (int pos = startPos+1; pos < FINAL_POSITION; pos++)
        if (board[pos] == color)
            return pos;
    return FINAL_POSITION;
}

// Description: find position of indicated person
// Parameters: name -- name of person to look for
// Returns: index of space for this name
int findPerson(string name) {
    if (name == PLUMPY) return 8;
    if (name == MR_MINT) return 17;
    if (name == JOLLY) return 42;
    cerr << "No such person in the game" << endl;
    return FINAL_POSITION; // should not get here -- just here to get program to stop
}

// Description: Move a player
// Parameters: player -- index of player to move
//             card -- indicates where to move
//             repeat -- true if card is a "double" color, false if not
//             positions -- where the players are
// Returns: new position of player after move
int move(int player, string card, bool repeat, int positions[]) {
    int nextPos = positions[player];
    
    if (isColor(card)) {
        nextPos = findColor(positions[player], card);
        if (repeat)
            nextPos = findColor(nextPos, card);
        return nextPos;
    }
    else return findPerson(card);
}

// Description: Check for a winner
// Parameters: positions -- where the players are
//             numPlayers -- how many there are
// Returns: true if there are no winners yet
//          false if anyone has won
bool nowinner(int positions[], int numPlayers) {
    for (int player = 0; player < NUM_PLAYERS; player++) {
        if (positions[player] == FINAL_POSITION) // reached the end
            return false;
        }
    return true;
}

// Description: Display welcome string
void printIntro() {
    cout << "This is a crude version of Candyland" << endl << endl;
}

// Generate the next value "drawn"
// Returns: the value of the next card drawn. Returning the empty string indicates
//          there are no more values
string draw() {
    string testRolls[] = {PLUMPY, YELLOW, RED, YELLOW, GREEN, MR_MINT, JOLLY, RED, GREEN};
    const int NUM_CARDS = 9;
    static int next = 0;
    
    if (next >= NUM_CARDS) return "";
    return testRolls[next++];
}

// Indicate if this card is a "double" color
// Returns: true if the color is a double, false if not.
// NOTE: This is a very bad way to do this -- but it does help to motivate structures
bool drawRepeat() {
    bool testRollsRepeat[] = {false, true, false, true, false, false, false, false, false};
    const int NUM_CARDS = 9;
    static int next = 0;
    
    if (next >= NUM_CARDS) return false;
    return testRollsRepeat[next++];
}

// Print the identity of the winner, if any.
// If there are no winners, do nothing.
// Parameters:
// positions -- the array indicating where the players are located
// numPlayers -- the number of players
void printWinner(int positions[], int numPlayers) {
    for (int player = 0; player < numPlayers; player++) {
        // Would be clearer to use a different constant to
        // explicitly define the winning position
        if (positions[player] == FINAL_POSITION)
            cout << "Player " << player << " wins!" << endl;
    }
}

// Description: Play the game
void playGame() {
    // Use nextPlayer to switch among the players
    int nextPlayer = 0;
    bool done = false;

    initialize(positions, NUM_PLAYERS);
    while (nowinner(positions, NUM_PLAYERS) && !done) {
        string nextCard = draw();
        bool repeat = drawRepeat();

        if ("" != nextCard) {
            positions[nextPlayer] = move(nextPlayer, nextCard, repeat, positions);
            cout << "Player " << nextPlayer << " is at position "
                 << positions[nextPlayer] << endl;
            nextPlayer = (nextPlayer + 1) % NUM_PLAYERS;
        }
        else done = true;
    }
    if (nowinner(positions, NUM_PLAYERS))
        cout << "No winner" << endl;
    else printWinner(positions, NUM_PLAYERS);
}

int main() {
        printIntro();
        playGame();
        return 0;
}

In: Computer Science