Questions
DATA STRUCTURES   What is returned when calling this method with the singly list contains (1,5,5,7,8)   public...

DATA STRUCTURES  

What is returned when calling this method with the singly list contains (1,5,5,7,8)  

public static int m1(SinglyList  list1)

{

  if(list1.size()!=2)

return list1.removeFirst()+m1(list1);

     return s;

}

In: Computer Science

1. Suppose that you want to program an AI agent to navigate out of a maze....

1. Suppose that you want to program an AI agent to navigate out of a maze. The agent starts at the maze’s center facing the north direction. The agent can turn to face the south, north, east, or west. The agent can be directed to move forward for a certain distance but will stop before hitting a wall.

a) Formulate this as a search problem defining initial state, goal test, transition function, and cost function.

b) What can you tell about the size of the state space?

c) In maze navigation, it is only necessary to turn at the intersection of two or more corri-dors. Using this observation, reformulate the search problem. What can you say about the size of the state space now?

d) What simplifications or abstractions about the real world, actions, or details did we make in our problem formulation? List three of this simplifications and briefly discuss how realistic they are. For example, we assume that the agent can move as far as it can without battery charging.

In: Computer Science

Explain the concept of information systems planning. Compare at least two development planning methods. Clarify why...

Explain the concept of information systems planning.

Compare at least two development planning methods.

Clarify why each planning method is appropriate for new system implementation

In: Computer Science

Programming How does readability can affect cost?

Programming

How does readability can affect cost?

In: Computer Science

IN JAVA: Build a class called ExamPractice from scratch. This class should include a main method...

IN JAVA: Build a class called ExamPractice from scratch. This class should include a main method that does the following:

  1. Prompt the user to enter a number of inches
  2. Read the number of inches entered from the console
  3. Convert the inches into an equivalent number of miles, yards, feet, and inches.
  4. Output the results to the console.

For example, if a user entered 100000 inches, the program would output:

100000 inches is equivalent to:
Miles: 1
Yards: 1017
Feet: 2

Inches: 4

In: Computer Science

CODE IN C++ PLEASE When you borrow money to buy a house, a car, or for...

CODE IN C++ PLEASE

When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first month’s interest on $1,000 is 1000 X 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 - 6 = 19. This means after making the first payment, the loan amount is 1,000 - 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 X 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 - 5.89 = 19.11 and the remaining balance after the second payment is 981 - 19.11 = 961.89. This process is repeated until the loan is paid. Instructions Write a program that accepts as input: The loan amount The interest rate per year The monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first month’s interest, then after each payment, the loan amount will increase.) In this case, the program must warn the borrower that the Monthly payment is too low. The loan cannot be repaid. Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.

In: Computer Science

1. Answer “True” or “False”. (a) A doubly linked list structure is worse than a singly...

1. Answer “True” or “False”.

(a) A doubly linked list structure is worse than a singly linked list if we plan to do a lot of insertions.

(b) A doubly linked list structure is worse than a singly linked list if we plan to do a lot of deletions.

(c) A doubly linked list structure is worse than a singly linked list if we plan to print the entire list frequently.

(d) An array implementation of a queue is more difficult to manage than the array implementation of a stack.

Solution:

In: Computer Science

JAVA program to simulate a customer’s online grocery shopping. The customer will shop fruit and vegetable...

JAVA program to simulate a customer’s online grocery shopping. The customer will shop fruit and vegetable each week online. The customer will select one vegetable and one fruit from the Table 1 and 2 respectively.

The program that is needed for the online ordering system will allow the customer to place a single order, calculating subtotals, additional fee, and outputting a shopping summary. When completing an order, an itemized summary is to be displayed. This bill should include a 3.5% service rate and flat fee of $5 for delivery should be added after the service fee has been applied to the bill.

Vegetable Name

Price Per Pound

Broccoli

$3.12

Yellow Onion

$1.15

Chili Pepper

$4.58

Greens Bundle

$2.82

Table 1: Vegetable names with corresponding price per pound

Fruit Name

Price Per Pound

Apple

$1.73

Grape

$2.15

Key Lime

$2.58

Navel Orange

$1.86

Table 2: Fruit names with corresponding price per pound

The main requirement of this program that is different from your earlier assignments is that you are required to create 2 different Java classes in the design of your program. Here are some other design details that may be helpful:

Design:

The classes should be placed in a package with the name edu.ilstu

The GroceryShopping class should have proper Javadoc comments

The GroceryShopping class

Keeps track of the information for 1 order. Write the class GroceryShopping that has the following fields:

Instance Variables:

  • Vegetable name: the vegetable name field is a String object that holds the name of the vegetable selected from the Table 1.
  • Fruit name: the fruit name field is a String object that holds the name of the fruit selected from the Table 2.
  • Vegetable price: this vegetable price field is a double that holds the per pound price of the selected vegetable.
  • Fruit price: this fruit price field is a double that holds the per pound price of the selected fruit.
  • Vegetable ordered: the vegetable ordered field is a double that holds the pounds of the selected vegetable ordered
  • Fruit ordered: the fruit ordered field is a double that holds the pounds of the selected fruit ordered

Named Constants

  • service rate: a double type constant for 3.5% service rate on the total money spent on the vegetable and fruit ordered (not include delivery fee)
  • Delivery fee: an integer type constant for 5 dollars delivery fee.

Methods:

  • Constructor: the constructor should accept the selected vegetable and fruit names along with the corresponding price per pound as arguments (please use Table 1 and 2 to choose the vegetable and fruit name and the corresponding price per pound). The constructor should also assign 0 to the fields of vegetable ordered and fruit ordered.
  • Getters for each instance variable
  • Setters for the pounds of the vegetable and fruit ordered
  • A method, calculateSubtotal, calculates the subtotal based on the selected vegetable and fruit, their price per pound and how many pounds ordered.
  • A method, calculateAdditionalFee that will calculate the total cost of delivery and service fee of the total vegetable and fruit ordered:

Additional fee = subtotal * service rate + delivery fee

  • A method, displayOrderSummary, that will display the title of “Grocery Shopping Order Summary”, names of the selected vegetable and fruit and the corresponding pounds ordered, as well as the subtotal, additional fee and the total bill with formatting (Please use the sample run as a reference).

GroceryShoppingApp class:

This is the starting point for the application which is the only class to contain a main method. You will use the GroceryShopping class here. For this program, the main method handles all of the input and output for the program and will perform the following tasks:

  • Display the Table 1 and 2
  • Create a GroceryShopping object using the values of the selected vegetable and fruit name and corresponding price per pound as input arguments (using Table 1 and 2).
  • Display the grocery shopping menu of vegetable and fruit items and their prices
  • Utilize methods in the GroceryShopping object to perform calculations and display the grocery shopping order summary
  • Follow the sample interaction on what to display for prompts, labels, messages and the flow for screen input and outputs.
    • Ask for how many pounds the customer wants to order for the selected vegetable and fruit
    • Update the GroceryShopping instance with the order numbers entered.
    • Display a summary of the grocery order, see sample run.
  • Review the sample run of the program to determine how the interaction with the user should flow.

Input:

  • Your program prompts the user to enter the selected vegetable name, then the price per pound
  • Next, the program prompts the user to enter the selected fruit name, then the price per pound
  • Then, it displays a Menu with the selected vegetable and fruit with their price per pound.
  • It should then prompt the user for the pounds of the selected vegetable he/she would like to order. After the number of pounds of the selected vegetable has been entered (which may be 0), the program should continue displaying a prompt and reading the number of pounds to order for the selected fruit.

Output:

Print the title, a line with the selected vegetable and the number of pounds purchased, a line with the selected fruit and the number of pounds purchased, a subtotal of the cost of the items ordered, additional fee, and the total bill.

In: Computer Science

write a javascript function called cal_modes that will take a List of numbers or strings as...

write a javascript function called cal_modes that will take a List of numbers or strings as input and returns a List of the most frequent values. If there's only one most-frequent value, it returns a single-element List.

example

cal_modes([3,4,5,5]) should return [5]
cal_modes([8.9, 1, 1]) should return [1]
cal_modes([2.5, -2, -2, 2.5]) should return [2.5]
cal_modes([3,3,4,4]) should return [3,4]
cal_modes([3,4,5]) should return [3,4,5], because all occur with equal frequency
cal_modes(["hi", "what", "where", "hi"]) should return ["hi”]

In: Computer Science

// ==== Challenge 1: Write your own closure ==== // Write a closure of your own...

// ==== Challenge 1: Write your own closure ====

// Write a closure of your own creation.

// Keep it simple! Remember a closure is just a function

// that manipulates variables defined in the outer scope.

// The outer scope can be a parent function, or the top level of the script.

/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */

// ==== Challenge 2: Implement a "counter maker" function ====

const counterMaker = () => {

// IMPLEMENTATION OF counterMaker:

// 1- Declare a `count` variable with a value of 0. We will be mutating it, so declare it using `let`!

// 2- Declare a function `counter`. It should increment and return `count`.

// NOTE: This `counter` function, being nested inside `counterMaker`,

// "closes over" the `count` variable. It can "see" it in the parent scope!

// 3- Return the `counter` function.

};

// Example usage: const myCounter = counterMaker();

// myCounter(); // 1

// myCounter(); // 2

// ==== Challenge 3: Make `counterMaker` more sophisticated ====

// It should have a `limit` parameter. Any counters we make with `counterMaker`

// will refuse to go over the limit, and start back at 1.

// ==== Challenge 4: Create a counter function with an object that can increment and decrement ====

const counterFactory = () => {

// Return an object that has two methods called `increment` and `decrement`.

// `increment` should increment a counter variable in closure scope and return it.

// `decrement` should decrement the counter variable and return it.

};

In: Computer Science

Describe the following disk concepts or compo- nents. a. Platter and recording surface. b. Track. c....

Describe the following disk concepts or compo- nents.
a. Platter and recording surface. b. Track. c. Cylinder. d. Read/write head.
e. Access-arm mechanism.

In: Computer Science

I'm confused about upper bound and worst case are different. Can you provide an explanation/examples to...

I'm confused about upper bound and worst case are different. Can you provide an explanation/examples to help me separate these two concepts in my mind?

In: Computer Science

The decimal value of ‘252’ has which of the following hexadecimal value: (choose one and explain)...

The decimal value of ‘252’ has which of the following hexadecimal value: (choose one and explain)

  1. FF
  2. F1
  3. FH
  4. FC

2) If the following are using default subnet masks, which one(s) of the following are valid node IP addresses: (select one and explain)

a) 220.1.1.255              b) 10.10.0.10    c) 208.5.48.0      d) 1.255.255.255

3) Which of the following are valid Private IP addresses? (Select all Valid choices)

Private IP address is an address that is reserved for internal use behind a router.

  1. 172.32.1.1
  2. 10.255.255.255
  3. 168.192.0.255
  4. 192.169.0.1

In: Computer Science

c++ question Question 2: X = 7777 Modify the code below and use conditional branching (if,...

c++ question

Question 2: X = 7777
Modify the code below and use conditional branching (if, else, etc.)
to print the following:
if X is between 0 and 33333 then print the word: red
if X is between 33334 and 66666 then print the word: blue
if X is between 66667 and 99999 then print the word: green
if none of the above condition matches then print the word: white

In: Computer Science

Suppose you are writing a program to compute the semester GPA for a person based on...

Suppose you are writing a program to compute the semester GPA for a person based on knowing the grades earned and the number of credit hours for each course taken.

What type of tests would you need to create to check that your program was working correctly? Be specific, and remember to keep in mind tests that might contain unexpected input. How would your program react to those?

After you have made your post, you need to provide thoughtful comments on at least two other posts (or replies).

Your original post is due Sep 8; your replies are due Sep 11.

In: Computer Science