Write a menu-driven program to implement a roomsboard for a classroom reservations system. The menu includes the following options:
The program will call the removeAll() method from the RoomsBoard class.
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 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 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 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 of active -passive.
In: Computer Science
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
A restaurant sells packs of chicken nuggets in various denominations. Using octave, Write a script that prompts the user for a vector of the available pack denominations. The script should then prompt the user for a vector of quantities of each denomination to be purchased. Finally, the script should calculate and print the total number of chicken nuggets that would be obtained from the purchase. Hint: Note that if you multiply (in the linear algebra sense) a 1 × n row vector and an n × 1 column vector you obtain a scalar: h a1 a2 a3 · · · an i b1 b2 b3 . . . bn = a1b1 + a2b2 + a3b3 + · · · anbn. Sample output: Enter the denominations in which chicken nuggets are available: [ 6 9 20 ] Enter the quantity of each denomination to be purchased: [ 1 1 1 ] The total number of chicken nuggets purchased is 35 Enter the denominations in which chicken nuggets are available: [ 4 10 50 8 ] Enter the quantity of each denomination to be purchased: [ 2 0 1 0 ] The total number of chicken nuggets purchased is 58. Also, use disp to print entire vectors of numbers.
In: Computer Science
C++
11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account: Customer name Customer address City State ZIP code Telephone Account balance Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Prompts And Output Labels. Your main menu should be the following: 1. Enter new account information 2. Change account information 3. Display all account information 4. Exit the program The user is expected to enter 1 or 2 or 3 or 4. The main menu is displayed at the start of the program and after the handling of choices 1, 2 and 3. If 1 is entered for the main menu, the program prompts for each of the data listed above, in the order listed above, using the above data descriptions (e.g. "ZIP code") as prompts (followed in each case by a colon). After reading in and processing the data, the program prints You have entered information for customer number X where X is the customer number: 0 for the first customer and increasing by 1 for each subsequent customer that is entered. If 2 is entered for the main menu, the program prompts for the customer number: Customer number: Upon entering a valid customer number the program displays all the data for the particular customer that has been saved: Customer name: ... Customer address: ... City: ... State: ... ZIP code: ... Telephone: ... Account balance: ... Date of last payment: ... The program then skips one or two lines and prompts for a change, using the same prompts as in choice 1 above for all the data items associated with a customer. If 3 is entered for the main menu, the program displays all the data for each customer that has been saved, using the display format in choice 2 above. After the display of each customer the program prompts "Press enter to continue..." and waits for the user to hit return. If 4 is entered for the main menu, the program terminates. Input Validation (OPTIONAL).When the data for a new account is entered, be sure the user enters data for all the fields. No negative account balances should be entered.
.make sure it good with codelab
In: Computer Science
In java
Step 1) Assume that you have tracked monthly BSIT inquires for 10 months. Save the following data into a text file in notepad in the order listed 40 22 17 35 28 17 22 28 25 19
Step 2) Write a java program that reads the monthly BSIT inquires for 10 months from the text file that you created in step 1. Read the monthly inquires from the input file into an array in one execution of the program. Write a sort method to sort the inquiry values lowest to highest. Write a method to calculate the average of the monthly inquiries. Write a method to determine the maximum value. Your program should call the sort, average and maximum methods. Create an output file to which you write the sorted array output, the average value and maximum value.
In: Computer Science
This is for Python programming, and I am trying to use 2 for loops to ask a slaesperson how many of 5 different items they sold, then the program is to calculate the total dollar amount sold. Formatting and all that aside, I am having an issue with the loops not stepping through the 2 lists at the same time. The first loop is taking all 5 entered quantities times the price of the first item, and then all 5 quantities times the price of the 2nd item, etc. I need to get Item1 * Quant1, Item2 * Quant2, etc.
Item1 = 2.5
Item2 = 1.98
Item3 = 5.75
Item4 = 3.45
Item5 = 4.0
Quant1 = int(input("Enter the quantity of Item1 sold: "))
Quant2 = int(input("Enter the quantity of Item2 sold: "))
Quant3 = int(input("Enter the quantity of Item3 sold: "))
Quant4 = int(input("Enter the quantity of Item4 sold: "))
Quant5 = int(input("Enter the quantity of Item5 sold: "))
for Item in [Item1, Item2, Item3, Item4, Item5]:
for Quant in [Quant1, Quant2, Quant3, Quant4, Quant5]:
Cost = float(Quant * Item)
print (Cost)
In: Computer Science
Create an object call Accounts using python for a banking
system.
Initialize the account with three data as inputs : Firstname,
Lastname and initial deposit. Create 4 additional member functions:
Deposit, Withdraw, Fee Calculations, interest
The fee calculation is going to be $14 per month if the total
amount in the account is less than $1000. Interest is set to be at
5%.
In: Computer Science
C++
11.11: Customer Accounts A student has established the following monthly budget: 500.00 Housing 150.00 Utilities 65.00 Household 50.00 Expenses 50.00 Transportation 250.00 Food 30.00 Medical 100.00 Insurance 150.00 Entertainment 75.00 Clothing 50.00 Miscellaneous Write a program that has a MonthlyBudget structure designed to hold each of these expense categories. The program should pass the structure to a function that asks the user to enter the amounts spent in each budget category during a month. The program should then pass the structure to a function that displays a report indicating the amount over or under in each category, as well as the amount over or under for the entire monthly budget. NOTES: For each of the categories listed above, and in that order, the program prompts the user for the the amount spent on X: where X is a category from the above list (e.g. "Insurance"). Using the values read into the structure, the program generates a table with a heading and in each row there are four items: the category (e.g. "Housing"), followed by the value budgeted for the category (500.00 in the case of Housing), followed by the value that had been read in for that category, followed by the amount that the actual spent was over or under the category budget. Finally, after the table, is an indication of whether the student is over or under budget.
make sure it works with codelab
In: Computer Science
the first few hops are the same for various websites?
In: Computer Science
In: Computer Science
At the college, two subnetworks have been set up:
The network administrator has connected several end-devices to these networks. A device is misconfigured. You are asked to identify this device.
a) An IP camera in network B with the following configuration: 192.168.22.129/26
b) A workstation in network B with the following configuration: 192.168.22.175/255.255.255.192
c) A printer in network A with the following configuration: 192.168.22.65/26
d) An IP camera in network B with the following configuration: 192.168.22.191/26
e) An IP camera in network A with the following configuration: 192.168.22.68/255.255.255.192
f) A laptop in network A with the following configuration: 192.168.22.117/255.255.255.192
g) An IP phone in network B with the following configuration: 192.168.22.170/255.255.255.192
h) A desktop in network A with the following configuration: 192.168.22.98/26
In: Computer Science