Questions
JAVA - Complete the directions in the 5 numbered comments import java.util.Scanner; /** * This program...

JAVA - Complete the directions in the 5 numbered comments

import java.util.Scanner;


/**
 * This program will use the HouseListing class and display a list of
 * houses sorted by the house's listing number
 * 
 * Complete the code below the numbered comments, 1 - 4. DO NOT CHANGE the
 * pre-written code
 * @author 
 *
 */

public class HouseListingDemo {

    public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
        HouseListing[] list;
        String listNumber, listDesc;
        int count = 0;
        double listPrice;
        String output;
        
        double mostExpensive;
        
         do{
            System.out.print("Enter the number of houses --> ");
           count = scan.nextInt();
        }while(count < 1);
         
        /* 1.
         * create an array of HouseListing objects using the variable that holds
         * the user's response to the prompt above
         */
        
        
        // for loop loads the array with HouseListing's constructor
        for (int i = 0; i < list.length; i++) 
        {
           System.out.println("\n***HOUSE " + (i+1) + "***");
           // Prompt for house listing #
           System.out.print("Enter house listing " +
                   "number (Alphanumeric) #"+ (i+1) +": ");
           listNumber = scan.next();
           
           // Clear buffer
           scan.nextLine();
           
           // Prompt for house description
           System.out.print("Enter description for " +
                   "house #" +(i+1) + ": ");
           listDesc = scan.nextLine();
           
           // Prompt for house price
           System.out.print("Enter listing price for " 
                   + "house #" +(i+1) + ": ");
           listPrice = scan.nextDouble();
           
            /* 2.
             * create a HouseListing object using the input values and store/load
             * the object in the array
             */
        }
        
        
        /* 3.
         * Assign the 0th element of the array to the most expensive house
           think ... you can't assign an object to a price but the object
           has a method that may help you here ... 
         */
        
        
        output = "Listings:\n";
        /*
         * loop below builds the output string
         */
        for (int i = 0; i < list.length; i++) {
            output += list[i] + "\n";
            
            /* 4.
              Using a control structure, find and the store the double varaible
              which holds the most expensive house (We don't need to listing #)
              JUST THE PRICE
            */
        }
        // output
         System.out.println(output);
        System.out.println("The most expensive house on the market costs: $" 
        + mostExpensive);
    }
}

In: Computer Science

A group of 2 n 1 routers are interconnected in a centralized binary tree, with a...

A group of 2 n 1 routers are interconnected in a centralized binary tree, with a router ateach tree node. Router i communicates with router v by sending a message to the root of the tree. The root then sends the message back down to u. Derive an expression for the average number of hops per message for a router to communicate with another router. You do not have to simplify the expression derived. Hint. Use the height of a router from the root the tree.

In: Computer Science

(a) Consider the following MIPS memory with data shown in hex, which are located in memory...

(a) Consider the following MIPS memory with data shown in hex, which are located in memory from address 0 through 15. Show the result of the MIPS instruction “lw $s0, 4($a0)” for machines in little-endian byte orders, where $a0 = 4.  

Address

Contents

0

8a

1

9b

2

a3

3

b4

4

c5

5

6d

6

7e

7

8f

Address

Contents

8

0a

9

1b

10

2c

11

3d

12

4e

13

5f

14

66

15

70

(b) )Assume we have the following time, performance and architecture parameters in the specified units.

Ec = execution time in cycles/program

Es = execution time in seconds/program

Pr = performance rate in instructions/seconds

CCT = clock cycle time in second/cycle

CR = clock rate in cycle/second

IC = instructions in instructions/program

CPI = average cycles per instruction in cycle/instruction

Complete the following formulas with the appropriate parameter

      CR = 1/____,                ____ = IC´ CPI,             Es =  ____ ´ CPI ´ CCT

In: Computer Science

Write a C++ program that uses a de-duplication function that iteratively sanitizes (removes) all consecutive duplicates...

Write a C++ program that uses a de-duplication function that iteratively sanitizes (removes) all consecutive duplicates in a C++ string. Consecutive duplicates are a pair of duplicate English alphabets sitting next to each other in the input string. Example: "AA", "KK", etc., are all consecutive duplicates. This function will internally run as many iterations as needed to remove all consecutive duplicates until there is either no consecutive duplicates left, or the string becomes empty (in which the function returns "Empty" back to the user):

string deduplicate(string input)

Your main() may look like the following, or anything you prefer to put in it as it is not graded:

int main() {
  cout << deduplicate("AABB"); // should output "Empty"
  cout << deduplicate("A"); // "A"
  cout << deduplicate("ABBA"); // should output "Empty"
  cout << deduplicate("AAA"); // "A"
  cout << deduplicate("AKA"); // "AKA" because there is no consecutive pair.
  return 0;
}

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

Examples:

  • "KCCK" -> first iteration results in "KK" by removing "CC" as consecutive duplicates -> second iteration starts with "KK" as consecutive duplicates hence removed. Function returns "Empty".
  • "ZZZ" -> first iteration results in "Z" by removing the first "ZZ". There is nothing to be removed after that. Function returns "Z".
  • "KKCCD" -> first iteration removes "KK" resulting in "CCD" -> second iteration removes "CC" resulting in "D". There is nothing left to be removed. Function return "D".

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

Constraints/Assumptions:

  • Input string consists of only uppercase English alphabets, "A" - "Z".
  • Input string consists of at least 1 English alphabet.
  • Input string consists of at most 100 alphabets.
  • Function returns the non-reducible string.
  • If the reduced string is empty, function returns the string "Empty".

In: Computer Science

Write the following questions as queries in SQL. Use only the operators discussed in class (no...

Write the following questions as queries in SQL. Use only the operators discussed in class (no outer joins)

Consider the following database schema:

INGREDIENT(ingredient-id,name,price-ounce)

RECIPE(recipe-id,name,country,time)

USES(rid,iid,quantity)

where INGREDIENT lists ingredient information (id, name, and the price per ounce); RECIPE lists recipe information (id, name, country of origin, and time it takes to cook it); and USES tells us which ingredients (and how much of each) a recipe uses. The primary key of each table is underlined; rid is a foreign key to RECIPE and iid is a foreign key to INGREDIENT

Write the following queries in SQL.

1. Find the names of French recipes that use butter and take longer than 45 minutes to cook.

2. Find the names of recipes that use butter or lard.

3. Find the names of recipes that use butter and lard.

In: Computer Science

Question 1) The Following OOP Problem must be completed in C++ Consider a bubble gum dispenser.The...

Question 1)

The Following OOP Problem must be completed in C++

Consider a bubble gum dispenser.The dispenser releases one bubble gum at a time until empty. Filling of the dispenser adds a positive number of bubble gums.

A) Write an Abstract Data Type for a bubble gum dispenser

B) Draw the UML class diagram

C) Define a C++ class for a bubble gum dispenser object

D) The number of bubble gums in the dispenser is private

E) Write an implementation for the class

F) Write a simple test program to demonstrate that your class is implemented correctly

In: Computer Science

5.9 Online shopping cart (Java) Create a program using classes that does the following in the...

5.9 Online shopping cart (Java)

Create a program using classes that does the following in the zyLabs developer below. For this lab, you will be working with two different class files. To switch files, look for where it says "Current File" at the top of the developer window. Click the current file name, then select the file you need.

(1) Create two files to submit:

  • ItemToPurchase.java - Class definition
  • ShoppingCartPrinter.java - Contains main() method

Build the ItemToPurchase class with the following specifications:

  • Private fields
  • String itemName - Initialized in default constructor to "none"
  • int itemPrice - Initialized in default constructor to 0
  • int itemQuantity - Initialized in default constructor to 0
  • Default constructor
  • Public member methods (mutators & accessors)
  • setName() & getName() (2 pts)
  • setPrice() & getPrice() (2 pts)
  • setQuantity() & getQuantity() (2 pts)

(2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call scnr.nextLine(); to allow the user to input a new string. (2 pts)

Ex:

Item 1
Enter the item name: Chocolate Chips
Enter the item price: 3
Enter the item quantity: 1

Item 2
Enter the item name: Bottled Water
Enter the item price: 1
Enter the item quantity: 10


(3) Add the costs of the two items together and output the total cost. (2 pts)

Ex:

TOTAL COST
Chocolate Chips 1 @ $3 = $3
Bottled Water 10 @ $1 = $10

Total: $13

In: Computer Science

need this in C++ Start Declarations number currentTuition number futureTuition number interestRate number numYears number year...

need this in C++

Start

Declarations

number currentTuition

number futureTuition

number interestRate

number numYears

number year

output "Please enter current tuition: "

input currentTuition

output "Please enter interest rate (e.g. 9.0 for 9 percent): "

input interestRate

output "Please number of years for tuition: "

input numYears

output “Tuition at year 1 is “, currentTuition

futureTuition = currentTuition

for year = 2 to numYears

futureTuition = futureTuition * (1 + interestRate/100)

output “Tuition at year “, year ,”is “, futureTuition

endfor

Stop

In: Computer Science

Ann is planning to purchase some items. The store is having a sale, where if you...

  1. Ann is planning to purchase some items. The store is having a sale, where if you buy one item the 2nd item (of equal or lower value) is 50% off. The tax on each item is 7%.                                                                                                                    
  • Item 1 costs $39.75 before taxes.
  • Item 2 costs $65.50 before taxes.
    1. If Ann only buys Item 2, what is the total cost of her purchase after taxes? Display this value (rounded to the nearest cent) with a suitable message.
    2. If Ann buys Item 1 and Item 2, what is the total cost after taxes? Display this value (rounded to the nearest cent) with a suitable message.
    3. If Ann buys Item 1 and Item 2, how much money does Ann save before taxes, due to the sale? Display this value (rounded to the nearest cent) with a suitable message.

In: Computer Science

Let a , b , c be three integer numbers. Write a C++ program with a...

Let a , b , c be three integer numbers. Write a C++ program with a functions

void rotate1(int* a,int* b,int* c)
void rotate2(int& a,int& b,int& c)

such that a -> b , b -> c and c -> a. Thus we use two different approaches (pointers in rotate1 and references in rotate2).

In: Computer Science

The threat on the Texas power grid has escalated. An imminent attack is expected coming from...

The threat on the Texas power grid has escalated. An imminent attack is expected coming from multiple fronts. This includes expected coordinated attacks including DDOS, malware, and physical attacks on substation equipment. To secure the grid against such an attack, formulate an effective defense scenario and strategies to counter the cyber attack.   This includes deceiving, confining, and neutralizing the attackers before it actually occurs, keeping the grid up.

In: Computer Science

Data Structure 6. Write a recursive routine that will have an integer array and an index...

Data Structure

6. Write a recursive routine that will have an integer array and an index as parameters and will return the count of all odd integers. You may assume that the index starts out at the END of the array.

12. Write the implementation function for ArrayBag in C++, called bagLess, that takes an ItemType of item as parameters and use it count items in the current bag that are less than the item (hint: use toVector)

13. Write a sum function in C++ for LinkedBag of integers (must use pointers to traverse the linked list) that will return a sum of all values.

15. Write a Grammar that starts with a letter or a group of letters (assume uppercase), has an '?' or '!', and ends with a letter or a group of letters (uppercase)

16.

Given: e + f / (a – b) * c

Write out the prefix form

In: Computer Science

Using Java Write a program that reads a file of numbers of type int and outputs...

Using Java

Write a program that reads a file of numbers of type int and outputs all of those numbers to another file, but without any duplicate numbers. You should assume that the input file is sorted from smallest to largest with one number on each line. After the program is run, the output file should contain all numbers that are in the original file, but no number should appear more than once. The numbers in the output file should also be sorted from smallest to largest with one number on each line.

Your program should not assume that there is a fixed number of entries to be read, but should be able to work with any number of entries in both the input and output files.

- Do not use arrays, lists, arraylists, linked lists, sets, maps, trees, or any other multi-element data structure.

program should read in and write out numbers from the input and output files at the same time, eliminating duplicates from the output file as you go.

Your program should obtain both file names from the user. For the original (input) file, create a text file that stores one number per line with several duplicates in sorted order. The output file should be created by your program. When completed, your program should display on the console:

  1. a count of numbers in the input file
  2. a count of the numbers in the output file
  3. and the number of duplicates found in the input file

Sample console dialog, where input from the user is underlined in italics

  Enter input file name or full path: numbers.txt
  Enter output file name or full path: output.txt
  There were 18 numbers input, 10 output, and 8 duplicates.  

In: Computer Science

please provide steps as you solve the question. >>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>

please provide steps as you solve the question.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>

Prove that the following languages are not regular using the pumping lemma.

a. ? = {? ?? ?? ? | ?, ? ≥ ?}

b. ? = {? ∈ {?, #} ∗ | ? = ??#??# … #?? ??? ? ≥ ?, ?? ∈ ? ∗ ??? ????? ?, ??? ?? ≠ ?? ??? ????? ? ≠ ?

} Hint: choose a string ? ∈ ? that contains ? #’s.

In: Computer Science

python: modify an image (just show me how to write the two functions described below) 1.One...

python: modify an image (just show me how to write the two functions described below)

1.One way to calculate the contrast between two colours is to calculate the brightness of the top pixel (the average of the red, green and blue components, with all three components weighted equally), and subtract the brightness of the pixel below it. We then calculate the absolute value of this difference. If this absolute value is greater than a threshold value, the contrast between the two pixels is high, so we change the top pixel's colour to black; otherwise, the contrast between the two pixels is low, so we change the top pixel's colour to whiteDevelop a filter named detect_edges that returns a copy of an image, in which the copy has been modified using the edge detection technique described in the preceding paragraphs. This filter has two parameters: an image and a threshold, which is a positive number.

2.As before, we calculate the contrast of two pixels by subtracting the brightness values of the pixels and calculating the absolute value of the difference. We change a pixel's colour to black only if the contrast between the pixel and the one below it is high (i.e., the absolute value of the difference exceeds the filter's threshold attribute) or the contrast between the pixel and the one to the right of it is high. Otherwise, we change the pixel's colour to white.


  1. A simple algorithm for performing edge detection is: for every pixel that has a pixel below it, check the contrast between the two pixels. If the contrast is high, change the top pixel's colour to black, but if the contrast is low, change the top pixel's colour to white. For the bottom row (which has no pixels below it), simply set the pixel to white.

In: Computer Science