Questions
The chapter metiones acitve-passive clustering configurations. Define what that is, and why would you use it.

The chapter metiones acitve-passive clustering configurations. Define what that is, and why would you use it.

In: Computer Science

c++120 Holideals at the Movies! We have special movie tickets on holidays! Prices are discounted when...

c++120

Holideals at the Movies!

We have special movie tickets on holidays! Prices are discounted when you buy a pair of tickets.

Create a program for the HoliDeals event that computes the subtotal for a pair of tickets. The program should ask the the ages of the first and second guests to compute the price.

There are different pricing structures based on the guests' age.

Children tickets cost $10 (age below 13)

Young Adult tickets cost $13 (age below 21)

Adult tickets cost $15 (age below 65)

Senior tickets cost $10 (age 65 and over)

To simplify the problem, let's assume that parents/guardians will always accompany pairs of children who will watch a movie.

The pricing structure should be displayed to the user. Please see the sample output below to guide the design of your program.

Welcome to HoliDeals at the Movies!
Tickets tonight can only be bought in pairs.
Here are our movie ticket deals:

Children - $10.00
Young Adults - $13.00
Adults - $15.00
Seniors - $10.00

Please enter the age of the person for the first guest: 15
Please enter the age of the person for the second guest: 16

The Subtotal for the ticket cost is: $26.00.

Q2:

Salary Calculator

Create a program that computes the salary based on an employee's hourly wage and hours worked. Use the following formulas:

Less than or equal to 40 hours worked

hourly wage * hours worked

Over 40, but less than or equal to 65 hours worked

(hourly wage * 40) + (hours worked - 40) * (hourly wage * 1.5)

Over 65 hours worked

(hourly wage * 40) + (hourly wage * 1.5) * 25 + (hours worked - 65) * hourly wage * 2

Please see the sample output below to guide the design of your program.

Hourly wage: 12
Hours worked: 20
Total Salary Owed: $240.00

In: Computer Science

Describe the components of Hyper-V and the process for installing it.

Describe the components of Hyper-V and the process for installing it.

In: Computer Science

Define predicates and prove the following using the appropriate rules of inference: All action movies are...

Define predicates and prove the following using the appropriate rules of inference:

All action movies are popular. There is an action movie filmed in Iowa. Therefore, some popular movie was filmed in Iowa.

In: Computer Science

In python, Modify your mapper to count the number of occurrences of each character (including punctuation...

In python,

Modify your mapper to count the number of occurrences of each character (including punctuation marks) in the file.

Practice the given tasks in Jupyter notebook first before running them on AWS. If your program fails, check out stderr log file for information about the error.

import sys
sys.path.append('.')

for line in sys.stdin:
   line = line.strip() #trim spaces from beginning and end
   keys = line.split() #split line by space
   for key in keys:
       value = 1
       print ("%s\t%d" % (key,value)) #for each word generate 'word TAB 1' line

In: Computer Science

In python, 1- Modify your mapper to count words after removing punctuation marks during mapping. Practice...

In python,

1- Modify your mapper to count words after removing punctuation marks during mapping.

Practice the given tasks in Jupyter notebook first before running them on AWS. If your program fails, check out stderr log file for information about the error.

import sys
sys.path.append('.')

for line in sys.stdin:
   line = line.strip() #trim spaces from beginning and end
   keys = line.split() #split line by space
   for key in keys:
       value = 1
       print ("%s\t%d" % (key,value)) #for each word generate 'word TAB 1' line

In: Computer Science

Working with strings can lead to various security flaws and errors in software development using the...

Working with strings can lead to various security flaws and errors in software development using the C++ language. What are the common string manipulation errors that can be encountered? How can these errors be resolved and/or limited? What tips can be utilized to identify security vulnerabilities related to strings in C++? Be sure to provide an appropriate source code example to illustrate your points.

In: Computer Science

Write a program that first asks the user to input 10 different integers a_1-a_10 and another...

Write a program that first asks the user to input 10 different integers a_1-a_10 and another integer b, then outputs all the pairs of the integers a_i and a_j satisfying a_i+a_j=b, i!=j. If there is no such pair, output “not found.”

In: Computer Science

Write a class to keep track of a balance in a bank account with a varying...

Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the interest rate to some initial values (with defaults of zero).

The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or withdrawal (subtract from the balance). You should not allow more money to be withdrawn than what is available in the account, nor should you allow for negative deposits.

Finally, there should be a function that adds interest to the balance (interest accrual) at the current interest rate. This function should have a parameter indicating how many months’ worth of interest are to be added (for example, 6 indicate the account should have 6 months’ added). Interest is accrued from an annual rate. The month is representative of 1/12 that amount. Each month should be calculated and added to the total separately.

For example:

            1 month accrued at 5% APR is Balance = ((Balance * 0.05)/12) + Balance;

            For 3 months the calculations you repeat the statement above 3 times.

Use the class as part of the interactive program provided below.

THERE ARE 3 DOCUMENTS

FILE Account.cpp:

#include "Account.h"

//constructor

Account::Account()

{

balance = 0;

rate = .05;

}

Account::Account(double startingBalance)

{

balance = startingBalance;

rate = .05;

}

double Account::getBalance()

{

return balance;

}

FILE Account.h:

#pragma once

class Account

{

private:

double balance;

double rate;

public:

Account();

Account(double);//enter balance

double getBalance();

double getRate();

};

FILE Source.cpp:

#include <iostream>
#include "Account.h"

using namespace std;
int menu();
void clearScreen();
void pauseScreen();
int main()
{
   int input = 0;
   double balance = 0.0, amount = 0.0;
   int month = 0;
   Account acct(100.00); //create instance of account
   do
   {
       input = menu();
       switch (input)
       {
           case 1: cout << acct.getBalance();
           pauseScreen();
           break;
           case 2: cout << acct.getRate();
           pauseScreen();
           break;
           case 3:
               cout << "Enter amount :";
               cin >> amount;
               if(amount < 0.0)
               {
                   cout << "Amount should be more than 0." << endl;
               }
               else
               {
                   acct.deposit(amount);
               }
           break;
           case 4:
               balance = acct.getBalance();
               cout << "Enter amount: ";
               cin >> amount;
               if(amount > balance || amount < 0.0)
               {
                   cout << "balance is less than entered amount OR you entered nagative amount." << endl;
               }
               else
               {
                   acct.withdrown(amount);
               }
           break;
           case 5:
              
               cout << "Enter month: " << endl;
               cin >> month;
               if(month < 1)
               {
                   cout << "Month should be more than 0" << endl;
               }
               acct.AccrueInterest(month);
           break;
           case 6: //ToDo
           cout << "Goodbye";
           pauseScreen();
       }
       clearScreen();
   } while (input != 6);
}
int menu()
{
   int input;
   cout << "Enter the number for th eoperation you wish to perform from the menu." << endl
   << "1. Check Balance" << endl
   << "2. Check Current Rate" << endl
   << "3. Deposit to Account" << endl
   << "4. Withdraw from Account" << endl
   << "5. Accrue Interest" << endl
   << "6. Exit program" << endl << endl;
   cout << "Enter Choice: ";
   cin >> input;
   while (input < 1 or input > 6)
   {
       cout << "Enter a valid Choice from the menu: ";
       if (std::cin.fail())
       {
           std::cin.clear();
           std::cin.ignore(1000, '\n');
       }
       cin >> input;
   }
   return input;
}
void clearScreen()
{
   system("CLS");
   if (std::cin.fail())
   {
       std::cin.clear();
       std::cin.ignore(1000, '\n');
   }
}
void pauseScreen()
{
   std::cin.clear();
   std::cin.ignore(1000, '\n');
   std::cout << "\n---Enter to Continue!---\n";
   std::cin.get();
}

In: Computer Science

The Menu-driven Program: Write a menu-driven program to implement a roomsboard for a classroom reservations system....

  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.

add it to the following code:

package Chegg;
public class ReservedRoom {
    private String roomID; //data member declaration
    private String courseID;
    private int time;

    public ReservedRoom(String roomID, String courseID, int time) { // constructor

        this.roomID = roomID;
        this.courseID = courseID;
        this.time = time;
    }

    public String getRoom() { //get methods
        return roomID;
    }

    public String getCourse() {
        return courseID;
    }

    public int getTime() {
        return time;
    }

    @Override
    public String toString() { // return string representation of ReservedRoom Object
        return "ReservedRoom [roomID=" + roomID + ", courseID=" + courseID + ", time=" + time + "]";
    }

}

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

RoomsBoard class:

package Chegg;
public class RoomsBoard {
    ReservedRoomNode head;                 //Node for storing head of the list
    private int size=0;                    //variable for storing size
    public void add(ReservedRoom r)
    {
        ReservedRoomNode node=new ReservedRoomNode(r);
        ReservedRoomNode current;               //Node to traverse the list
        if(head==null|| head.getroom().getTime()>r.getTime())
        {
            node.setNext(head);
            head=node;
            size++;
        }
        else
        {
            current=head;
            while(current.getNext()!=null&& current.getNext().getroom().getTime()<r.getTime())
            {
                current=current.getNext();
            }
            node.setNext(current.getNext());
            current.setNext(node);
            size++;
        }

    }
    public void remove(String roomId)
    {
        if(head==null) {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head,temp=null;
        while(current!=null && current.getroom().getRoom()==roomId)
        {
            head=current.getNext();
            current=head;
            size--;
        }
        while(current!=null)
        {
            while(current!=null && current.getroom().getRoom()!=roomId)
            {
                temp=current;
                current=current.getNext();
            }
            if(current==null)
                return;
            temp.setNext(current.getNext());
            current=temp.getNext();
            size--;
        }
    }
    public void listRooms()
    {
        if(isEmpty()) {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;                   //Node to traverse the list
        while(current!=null)
        {
            System.out.print(current);
            current=current.getNext();
        }
        System.out.println();
        System.out.println("-------------------------------------------------");
    }
    public void remove_all_but(String roomId)
    {
        if(isEmpty()) {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;
        while(current.getroom().getRoom()!=roomId && current!=null)
        {
            current=current.getNext();
        }
        if(current==null)
            return;
        current.setNext(null);
        head=current;
        size=1;
    }
    public void removeAll()
    {
        head=null;                               //assigning null to head removes all nodes
        size=0;
    }
    public void split(RoomsBoard board1,RoomsBoard board2)
    {
        if(this.isEmpty())
        {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;
        while(current!=null)
        {
            if(current.getroom().getTime()<=12)                    //board1 will store rooms with  timings before and at 12
                board1.add(current.getroom());
            else
                board2.add(current.getroom());                     //board2 will store rooms with timings after 12
            current=current.getNext();

        }
        System.out.print("Rooms before and at 12:");
        System.out.println();
        board1.listRooms();
        System.out.println();
        System.out.println("Rooms after 12:");
        board2.listRooms();

    }
    public void listReservations(String roomID)
    {
        if(isEmpty())
        {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;
        while(current!=null)
        {
            if(current.getroom().getRoom()==roomID)
                System.out.println(current.getroom().toString());
            current=current.getNext();
        }
        System.out.println("--------------------------------------------------------");
    }
    public boolean isEmpty()
    {
        return head==null;
    }
    public int size()
    {
        return size;
    }
}

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

RoomsBoardMain class

package Chegg;

public class RoomsBoardMain {
    public static void main(String[] args) {
        ReservedRoom r1=new ReservedRoom("98","maths",15);
        ReservedRoom r2=new ReservedRoom("94","physics",12);
        ReservedRoom r3=new ReservedRoom("99","english",9);
        ReservedRoom r4=new ReservedRoom("98","geography",11);
        ReservedRoom r5=new ReservedRoom("99","history",18);
        ReservedRoom r6=new ReservedRoom("101","geology",22);
        ReservedRoom r7=new ReservedRoom("98","chemistry",11);
        RoomsBoard list=new RoomsBoard();
        RoomsBoard board1=new RoomsBoard();
        RoomsBoard board2=new RoomsBoard();

        list.add(r1);
        list.add(r2);
        list.add(r3);
        list.add(r4);
        list.add(r5);
        list.add(r6);
        list.add(r7);
        list.listRooms();
        System.out.println("------------------------------------------");
        list.remove("98");
        System.out.println("Reserverd Rooms after removing room with ID=98");
        list.listRooms();
        list.split(board1,board2);
        System.out.println("Reservation for Room with ID=99");
        list.listReservations("99");
        System.out.print("Number of Reservations is Empty: ");
        System.out.println(list.isEmpty());
        System.out.println("Number of Reserved Rooms: "+list.size());
        System.out.println("----------------------------------------");
        System.out.println("Removing all Reserved Rooms except with id=101");
        list.remove_all_but("101");
        list.listRooms();
        System.out.println("------------------------------------");
        System.out.println("After Removing all reservations");
        list.removeAll();
        list.listRooms();
    }
}

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

ReservedRoomNode class

package Chegg;

public class ReservedRoomNode {                                     //class for creating nodes of ReservedRoom
     ReservedRoom room;
    ReservedRoomNode next;
    public ReservedRoomNode(ReservedRoom room)                             //constructor for creating Node
    {
        this.room=room;
    }

    public ReservedRoom getroom() {
        return room;
    }

    public void setRoom(ReservedRoom room) {
        this.room = room;
    }

    public ReservedRoomNode getNext() {
        return next;
    }

    public void setNext(ReservedRoomNode next) {
        this.next = next;
    }

    @Override
    public String toString() {
        return room.toString() ;

    }
}

In: Computer Science

C programming assignment. instructions are given below and please edit this code only. also include screenshot...

C programming assignment.

instructions are given below and please edit this code only.

also include screenshot of the output

//In this assignment, we write code to convert decimal integers into hexadecimal numbers
//We pratice using arrays in this assignment
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

//convert the decimal integer d to hexadecimal, the result is stored in hex[]
void dec_hex(int d, char hex[])
{
   char digits[] ={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
                   'C', 'D', 'E', 'F'};

   int k = 0;
   //Fill in your code below
   //It should not be hard to obtain the last digit of a hex number
   //Then what?
   //If we are getting the digits in a reverse order, what should we do in the end?
  


   //Make sure the last character is a zero so that we can print the string correctly
   hex[k] = '\0';
}

// Do not change the code below
int main()
{
   int d;
   char hex[80];
  
   printf("Enter a positive integer : ");
   scanf("%d", &d);
   dec_hex(d, hex);
   printf("%s\n", hex);
   return 0;
}

In: Computer Science

Write a shell script that will create a new password-type file that contains user information. The...

Write a shell script that will create a new password-type file that contains user information. The file should contain information about the last five users added to the system with each line describing a single user. This information is contained in the last five lines of both the /etc/shadow and the /etc/passwd files. Specifically, you should produce a file where each line for a user contains the following fields: user name, encrypted password, and shell. The fields should be separated using the colon (:) character.

In: Computer Science

Answer these using VISUAL STUDIOS not CTT or PYTHON 1.Write an expression that evaluates to true...

Answer these using VISUAL STUDIOS not CTT or PYTHON

1.Write an expression that evaluates to true if the value of the integer variable x is divisible (with no remainder) by the integer variable y. (Assume that y is not zero.)

2.Write an expression that evaluates to true if the value of the integer variable numberOfPrizes is divisible (with no remainder) by the integer variable numberOfParticipants. (Assume that numberOfParticipants is not zero.)

3.Write an expression that evaluates to true if the integer variable x contains an even value, and false if it contains an odd value.

4.Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

In: Computer Science

What is an alternate configuration to an acitve-passive clustering configuration. Why would you use that instead...

What is an alternate configuration to an acitve-passive clustering configuration. Why would you use that instead of active -passive.

In: Computer Science

Write an implementation of the ADT stack that uses a resizeable array to represent the stack...

Write an implementation of the ADT stack that uses a resizeable array to represent the stack items. Anytime the stack becomes full, double the size of the array. Maintain the stack's top entry at the beginning of the array.

Use c++ to write this code.

In: Computer Science