Consider the following instance variable and method.
private int[] numbers;
public void mystery(int x)
{
for (int k = 1; k < numbers.length; k = k + x)
{
numbers[k] = numbers[k - 1] + x;
}
}
Assume that numbers has been initialized with the following values.
{17, 34, 21, 42, 15, 69, 48, 25, 39}
Which of the following represents the order of the values in numbers as a result of the call mystery(3) ?
Select one:
a. {17, 20, 21, 42, 45, 69, 48, 51, 39}
b. {17, 20, 23, 26, 29, 32, 35, 38, 41}
c. {17, 37, 21, 42, 18, 69, 48, 28, 39}
d. {20, 23, 21, 42, 45, 69, 51, 54, 39}
e. {20, 34, 21, 45, 15, 69, 51, 25, 39}

Answers

Answer 1

After Solving the code:

e. {20, 34, 21, 45, 15, 69, 51, 25, 39}

What is Code?
Code is a set of instructions written in a computer language that tell the computer how to perform a task. It is written in a programming language that is used to create applications and software programs. Code is written by software developers and programmers in order to define the behavior of a computer system. Code is composed of a series of instructions and commands which are written in a specific syntax and are designed to execute a certain set of tasks. The code is written in such a way that it can be understood and interpreted by the computer system. The code is then compiled and tested to ensure that it runs correctly and produces the desired results.

To know more about Code
https://brainly.com/question/26134656
#SPJ4


Related Questions

A programmer is developing a word game. The programmer wants to create an algorithm that will take a list of words and return a list containing the first letter of all words that are palindromes (words that read the same backward or forward). The returned list should be in alphabetical order. For example, if the list contains the words ["banana", "kayak", "mom", "apple", "level"], the returned list would contain ["k", "l", "m"] (because "kayak", "level", and "mom" are palindromes). The programmer knows that the following steps are necessary for the algorithm but is not sure in which order they should be executed. Executing which of the following sequences of steps will enable the algorithm to work as intended?
I. First shorten, then keep palindromes, then sort
II. First keep palindromes, then shorten, then sort
III. First sort, then keep palindromes, then shorten
Pilihan jawaban
a. I only
b. II only
c. I and III
d. II and III

Answers

Based on the above statement, pick (D) is the correct one. Prioritize palindromes, then shorten, and then sort III. Sorting was followed by shortening and retaining palindromes.

That would be what sort of an algorithm?

Common examples of algorithms include the method for baking a cake, the approach we use to solve a long division challenge, washing laundry, and running a search query.

What is the simple definition of an algorithm?

An algorithm is a technique used to do calculations or solve issues. Algorithms perform as a precise set of instructions which carry out preset activities consecutively in either hardware-based and software-based routines. Algorithms play a big role in information technology across the board.

To know more about Algorithm visit:

https://brainly.com/question/28650391

#SPJ4

itemtopurchase.h - class declaration itemtopurchase.cpp - class definition main.cpp - main() function (until you get to step 4, just use this main.cpp file to unit test your functions outside of zybooks. alternatively, you can create a test.cpp file that is only used outside of zybooks that contains all of your unit tests. in this case, leave the main function in main.cpp blank until you get to step 4.)

Answers

A default constructor Object() { [native code] } is one that either has no parameters or, if it does, contains default values for all of the parameters.

Class A does not have a user-defined function

Object() { [native code] }

but one is required, the compiler implicitly declares A::A() as the default parameterless function Object() { [native code] }.

ItemToPurchase.h

#ifndef ITEMTOPURCHASE_H_INCLUDED

#define ITEMTOPURCHASE_H_INCLUDED

#include<string>

#include <iostream>

using namespace std;

class ItemToPurchase

{

public

   //Declaration of default constructor

   ItemToPurchase();

   //Declaration of SetName function

   void SetName(string ItemName);

   //Declaration of SetPrice function

   void SetPrice(int itemPrice);

   //Declaration of SetQuantity function

   void SetQuantity(int itemQuantity);

   //Declaration of GetName function

   string GetName();

   //Declaration of GetPrice function

   int GetPrice();

   //Declaration of GetQuantity function

   int GetQuantity();

private:

   //Declaration of itemName as

   //type of string

   string itemName;

   //Declaration of itemPrice as

   //type of integer

   int itemPrice;

   //Declaration of itemQuantity as

   //type of integer

   int itemQuantity;

};

#endif

ItemToPurchase.cpp:

#include <iostream>

#include <string>

#include "ItemToPurchase.h"

using namespace std;

//Implementation of default constructor

ItemToPurchase::ItemToPurchase()

{

   itemName = "none";

   itemPrice = 0;

   itemQuantity = 0;

}

//Implementation of SetName function

void ItemToPurchase::SetName(string name)

{

   itemName = name;

}

//Implementation of SetPrice function

void ItemToPurchase::SetPrice(int itemPrice)

{

   this->itemPrice = itemPrice;

}

//Implementation of SetQuantity function

void ItemToPurchase::SetQuantity(int itemQuantity)

{

   this->itemQuantity = itemQuantity;

}

//Implementation of GetName function

string ItemToPurchase::GetName()

{

//Implementation of GetPrice function

int ItemToPurchase::GetPrice()

{

   return itemPrice;

}

//Implementation of GetQuantity function

int ItemToPurchase::GetQuantity()

{

   return itemQuantity;

}

main.cpp

#include<iostream>

#include<string>

#include "ItemToPurchase.h"

using namespace std;

int main()

{

   //Declaration of ItemToPurchase class objects

   ItemToPurchase item1Cart, item2Cart;

   string itemName;

   //create a variable names like itemPrice

   //itemQuantity,totalCost as type of integer

   int itemPrice;

   int itemQuantity;

   int totalCost = 0;

   //Display statement for Item1

   cout << "Item 1:" << endl;

   cout << "Enter the item name : " << endl;

   //call the getline function

   getline(cin, itemName);

   //Display statememt

   cout << "Enter the item price : " << end

   cin >> itemPrice;

   cout << "Enter the item quantity : " << endl;

   cin >> itemQuantity;

   item1Cart.SetName(itemName);

   item1Cart.SetPrice(itemPrice)

   item1Cart.SetQuantity(itemQuantity);

   //call cin.ignore() function

   cin.ignore();

   //Display statement for Item

   cout << endl;

   cout << "Item 2:" << endl;

   cout << "Enter the item name : " << endl;

   getline(cin, itemName);

   cout << "Enter the item price : " << endl;

   cin >> itemPrice;

   cout << "Enter the item quantity : " << endl;

   cin >> itemQuantity;

   item2Cart.SetName(itemName);

   item2Cart.SetPrice(itemPrice);

   item2Cart.SetQuantity(itemQuantity);

   //Display statement

   cout << "TOTAL COST : " << endl;

   cout << item1Cart.GetName() << " " << item1Cart.GetQuantity() << " $" << item1Cart.GetPrice() << " = " << (item1Cart.GetQuantity()*item1Cart.GetPrice()) << endl;

   cout << item2Cart.GetName() << " " << item2Cart.GetQuantity() << "  $" << item2Cart.GetPrice() << " = " << (item2Cart.GetQuantity()*item2Cart.GetPrice()) << endl;

   totalCost = (item1Cart.GetQuantity()*item1Cart.GetPrice()) + (item2Cart.GetQuantity()*item2Cart.GetPrice());

   cout << endl;

   cout << "Total : $" << totalCost << endl;

   return 0;

}

   return itemName;

}

To learn more about default constructors click here:

brainly.com/question/29999428

#SPJ4

Complete question:

ItemToPurchase.h - Class declaration

ItemToPurchase.cpp - Class definition

main.cpp - main() function

Build the ItemToPurchase class with the following specifications:

Default constructorPublic class functions (mutators & accessors)

SetName() & GetName() (2 pts)

SetPrice() & GetPrice() (2 pts)

SetQuantity() & GetQuantity() (2 pts)

Private data members

string itemName - Initialized in default constructor to "none"

int itemPrice - Initialized in default constructor to 0

int itemQuantity - Initialized in default constructor to 0

c the program asks the user for a value of type double, calculates the square root of the value to one percent precision, using the babylonian, and outputs the calculated square root as well as how many iterations it took to calculate the square root. then ask for another value until the user enters zero.

Answers

C program asks the user for value of type double: #include <stdio.h>

#include <math.h>

int main() {

double input

How many iterations are required to calculate the square root?

#include <stdio.h>

#include <math.h>

int main() {

   double input, guess, root, error;

   int iterations;

   do {

       printf("Enter a value (or 0 to quit): ");

       scanf("%lf", &input);

       if (input == 0) {

           break;

       }

       guess = input / 2.0;

       root = sqrt(input);

       error = fabs((root - guess) / root);

       iterations = 0;

       while (error > 0.01) {

           guess = (guess + input / guess) / 2.0;

           root = sqrt(input);

           error = fabs((root - guess) / root);

           iterations++;

       }

       printf("The square root of %.2lf is %.2lf (calculated to 1%% precision in %d iterations)\n", input, guess, iterations);

   } while (input != 0);

   return 0;

}

What is C programming?

Because it may be used for low-level programming, C language is a system programming language (such as drivers and kernels). Typically, it is used to develop kernels, operating systems, drivers, and hardware. The C-based Linux kernel is one example. It cannot be used for web programming in languages like PHP,.NET, or Java.

To learn more about  program in C visit:

https://brainly.com/question/7344518

#SPJ4

how are a male and female human skeleton both similar and different

Answers

Answer:

Both skeletons are made up of 206 bones. They mainly contain a skull, rib cage, pelvis, and limbs. The main function of both skeletons is the provide support to the body while allowing movement. However, bone mass, density, structure and length differ in a male and female body. Female bones are lighter, and their pelvic cavities are broader to support childbirth, whereas male bones are heavier and sturdier.

Explanation:

FILL IN THE BLANK. when you create a(n) ___ query, the value the user enters in the dialog box determines which records the query displays in the results.

Answers

The blank can be filled with "parameter" to complete the sentence. When creating a parameter query in a database management system, the query prompts the user to input a value or criterion before it is executed.

When creating a parameter query in a database management system, the query prompts the user to input a value or criterion before it is executed. The entered value is used to filter the records in the results of the query. Parameter queries are useful for filtering records based on user-specified criteria, making them a powerful tool for customizing the output of a query. By allowing users to specify the criteria for the results of the query, parameter queries can make the querying process more efficient and user-friendly.

Learn more about database management system:

https://brainly.com/question/13467952

#SPJ4

Aegeus has been asked to create a report outlining the security risk of improper error handling. Which of the following would Aegeus include on his report?
a. It can slow down the overall system so that security appliances
cannot be used to monitor its processes.
b. It could potentially provide an attacker to the underlying OS.
c. It will cause error messages to appear on the screen that could
contain fake instructions telling the user to perform an insecure
action.
d. It can result in all other applications that are currently running to
abort and send erroneous data across the network.

Answers

Aegeus would include option (b) on his report as an important security risk associated with improper error handling.

When errors are not handled properly, they may reveal system details or vulnerabilities to an attacker, potentially allowing them to gain unauthorized access or escalate their privileges within the system.This can occur when error messages contain detailed system information, such as file paths or application configurations, which an attacker can use to their advantage. Additionally, unhandled errors can cause crashes or other unpredictable behavior that may leave the system in an insecure state.

Options a, c, and d are also potential risks associated with improper error handling, but they do not directly relate to security concerns. Option a may impact the ability to monitor system processes, option c may lead to user error, and option d may result in data corruption or other system issues, but they are not specifically related to security.

To know more about security visit:

https://brainly.com/question/13315284

#SPJ1

which of the following are conclusions of the newport 2014 study on technology use by age range? (choose all that apply.)

Answers

A. Older generations are more likely to own a computer than younger generations.

B. Technology use has increased significantly in all age ranges over the past decade.

C. Technology use is highest among adults in their twenties and thirties.

What is technology
Technology is the application of scientific knowledge for practical purposes, especially in industry. It can refer to machinery, hardware, software, techniques and methods of organization used to solve a problem. Technology is constantly changing and advancing, creating new opportunities and challenges. It helps us to be more efficient, productive and connected. Technology is used to design better products, improve services and make tasks easier, faster and more efficient. Technology can also be used to collect data and make decisions, automate processes, improve communication and collaboration, and provide access to information. Technology is also used to develop new products, enable new businesses and innovate existing ones.

To know more about technology
https://brainly.com/question/9171028
#SPJ4

Which is a method for activating a member function.

A. object_name.function_name

B. function_name.object_name

Answers

A method for activating a member function is as follows:

object_name.function_name.

Thus, the correct option for this question is A.

What is meant by member function?

Member function may be characterized as a type of function that includes the members of a class. They do not include operators and functions declared with the friend specifier. These are called friends of a class.

You can significantly declare a member function as static. This is usually referred to as a static member function. While other represents the motile or migratory member function. The types of member functions may generally include Simple functions, Static functions, Const functions, Inline functions, and Friend functions.

Therefore, the correct option for this question is A.

To learn more about Member functions, refer to the link:

https://brainly.com/question/30009557

#SPJ1

additional IPv4 routing controls are provided by the options. What is the boundary where the options must end?

Answers

The optional 14th field causes the IPv4 header's size to vary (options). The IPv4 header's size is indicated by the IHL field, which includes 4 bits that describe how many 32-bit words are included in the header.

What IPv4 header field varies from router to router?

Checksum: Every router's checksum field is updated in tandem with the other fields' values. TTL (Time to Live): The TTL field is decreased by one after each hop. Because of this, every router updates this field.

What IPv4 protocol field is used to regulate the number of routers?

Time to Live is referred to as TTL. Based on the number of hops the IP packet makes (Number of routers), this parameter indicates the IP packet's lifetime.

To know more about IPv4 visit:-

https://brainly.com/question/15074281

#SPJ4

Daniel wants to buy a computer to use for playing games after work. He loves racing games and wants to make sure his device has all the specifications needed to run them smoothly and efficiently. Which of these factors should he consider?
Processor core - some applications, especially games, have greater processor requirements

Answers

When looking to buy a computer for playing games, particularly racing games, there are several factors that Daniel should consider to ensure that the device can run the games smoothly and efficiently.

One important factor is the graphics card. Racing games require a high-performance graphics card to render the graphics, animations, and visual effects that are an integral part of the gameplay. A graphics card with a dedicated memory will be ideal.The CPU is another important factor to consider. Racing games require a fast processor to handle the physics calculations, AI routines, and other game mechanics. A high-performance processor with multiple cores will enable the computer to handle these tasks effectively.The amount of RAM is also important. A minimum of 8 GB of RAM is recommended to run modern games, although 16 GB or more is preferable for optimal performance.Finally, storage is an important consideration. A solid-state drive (SSD) will be ideal as it can provide fast read and write speeds, enabling faster load times for games.

To know more about computer visit:

https://brainly.com/question/25054163

#SPJ1

If anyone doesn't mind, please help me. Thank you!

Answers

Master will print infinitely since we are never changing the value of x.

Write a function select of this type: 'a list ('a -> bool) -> 'a list that takes a list and a function fas parameters. Your function should applyf to each element of the list and should return a new list containing only those elements of the original list for which f returned true. (The elements of the new list may be given in any order.) For example, evaluating select ([1,2,3,4,5,6,7,8,9,10), is Prime) should result in a list like [7,5, 3,2]. This is an example of a higher-order function, since it takes another function as a parameter. We will see much more about higher-order functions in Chapter 9

Answers

The function select takes a list and a function as input parameters, applies the function to each element of the list, and returns a new list containing only those elements for which the function returns true.

Below is the implementation of select function in python programming.

def select(lst, func):

   return [x for x in lst if func(x)]

This function takes a list lst and a function func as parameters. It applies the func to each element of the lst using a list comprehension and returns a new list containing only those elements for which the func returns true.

To use the select function to find prime numbers from a list, we can define the is_prime function as follows:

def is_prime(n):

   if n <= 1:

       return False

   for i in range(2, int(n**0.5) + 1):

       if n % i == 0:

           return False

   return True

Then, we can call the select function with the list and the is_prime function as follows:

lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

result = select(lst, is_prime)

print(result)

This will output: [2, 3, 5, 7], which are the prime numbers in the list.

The output of the code is attached.

You can learn more about list in python at

https://brainly.com/question/30396386

#SPJ4

consider program p, which runs on a 5 ghz machine m in 250 seconds. consider an optimization to p that replaces all instances of multiplying a value by 4 (mult x,x,4) with two instructions that set x to x x twice (add x,x; add x,x). assume that every multiply instruction takes 4 cycles to execute, and every add instruction takes just 1 cycle. after recompiling, the program now runs in 240 seconds on machine m. determine how many multiplies were replaced by this optimization. in your answer, show all of your calculations and analysis.

Answers

On machine m, the optimised programme p' would execute in about 500 seconds as opposed to 250 seconds for the original programme p to execute on the same system.

Describe the optimum method.

To find solutions that maximise or decrease certain research criteria, such as minimising expenses associated with producing a thing or service, maximising profits, minimising the amount of raw materials needed to make a good, or maximising output, optimization techniques are often used.

How is system performance optimised?

Performance optimization refers to the process of altering a system to increase its functionality and hence increase its effectiveness and efficiency.

To know more about optimised programme visit:-

https://brainly.com/question/14541613

#SPJ4

compare and contrast the school of digital and that of industrial age 3 pages essay?​

Answers

The school of the digital age emphasizes the use of technology and digital tools in education.

What else does it emphasize?

It emphasizes collaboration, critical thinking, and problem-solving skills. The focus is on personalized learning and the use of data to inform instruction.

In contrast, the school of the industrial age was characterized by a factory model of education.

Students were expected to conform to a standard curriculum and were often assessed through standardized tests. The emphasis was on rote memorization and discipline, with little room for creativity or individuality.

Read more about digital age here:

https://brainly.com/question/26927099

#SPJ1

Computer-
Why do people use PDF over word document

Answers

Answer:

.PDF Are Universal: Ms Word is used to author document before converting to PDF.

2.Security: Businesses around the world faces hundreds of cyber-attacks daily, thereby exposing their confidential document to high risk, especially in our digitalized world.

3.Easy to Create: MS Word, Excel, Power Point or any other document can be easily to PDF format file.

Explanation:

Assume that your body mass index (BMI) program calculated a BMI of 41.6. What would be the value of
category after this portion of the program was executed?
# Determine the weight category.
if BMI < 18.5:
category= "underweight
elif BMI > 39.9:
category="morbidly obese"
elif BMI <= 24.9:
category= "normal"
elif BMI <= 39.9:
category="overweight"
The value of category will be

Answers

"The value of category will be 'morbidly obese'."

In this exercise you will write a program to encrypt and decrypt files using Caesar (shift) cipher and write the result in a new file. You will also perform a brute force attack using a dictionary to decrypt a message. You can read about the Caesar’s cipher or more generally shift ciphers at https://en.wikipedia.org/wiki/Caesar_cipher.
Use Java or Python 3 to implement your program.
The program will be run using command line with the following options:
java program_name –e key
(python)
The program encrypts the file that follows –e option using the key k (an integer) and stores the result in the file indicated as output file.
java program_name –d key
python
The program decrypts the file that follows –d option using the key (an integer) and stores the result in the file indicated as output file.
java program_name –c
python
The program cracks the file that follows –c by brute forcing the key and displays the result(s) on the screen along with the key(s) that is (are) used to get the result(s).
The non-alphabetic characters in the texts (numeric, punctuation, space, etc.) will stay intact after encryption and decryption. You can convert the message into all upper or lower case and work with only one case.
Think Make sure that your program is robust; that it does not crash on unexpected inputs. Thin about what kind of errors may come up in your program; list them all and handle them in your program.
Hint on brute-forcing:
When cracking a file, try all possible keys and for each decrypted text, check the words in it against a dictionary to see what percentage is in the dictionary. If say a 80% (or a threshold that you determine) or more are found in the dictionary, then you probably cracked the code. Display the result on the screen. Display all results that are at or above the threshold. A dictionary file is provided in the dropbox.

Answers

This exercise involves writing a program to encrypt, decrypt, and crack a file using the Caesar cipher with a provided dictionary.

This exercise involves writing a program to encrypt and decrypt files using the Caesar (shift) cipher, as well as performing a brute force attack to decrypt a message using a dictionary. The program should be run from the command line with different options, such as "-e" to encrypt, "-d" to decrypt, and "-c" to perform a brute force attack.

The program should be able to handle unexpected inputs and errors, such as invalid input files, incorrect keys, or missing arguments. It should also preserve non-alphabetic characters such as punctuation and spaces in the encrypted and decrypted files.

During a brute-force attack, the program should try all possible keys and compare the resulting decrypted message with a provided dictionary. If a certain percentage of the words in the message are found in the dictionary, the program assumes that the correct key has been found and displays the decrypted message and the key used to obtain it.

Overall, the program should be designed to be efficient, user-friendly, and secure. Care should be taken to prevent potential security vulnerabilities, such as buffer overflows or other attacks that could compromise the integrity of the input or output files.

Learn more about brute-force attack here:

https://brainly.com/question/28521946

#SPJ4

Consider the following pseudocode, assuming nested subroutines and static scope. procedure main g : integer procedure B(a: integer) x: integer procedure A(n integer) procedure R(m integer) write integer(x) x/:= 2-integer division ifx> 1 R(m 1) else A(m) body of B x:-a x a -- body of main B(3) write.integer(g) a) What does this program print (write_integer is the printing function in this code)? (10 pts) b) Show the frames on the stack when A has just been called. For each frame, show the static links on the stack (draw the stack and its activation records). (5 pts) c) Explain how A can find the value of g (Hint: See section 3.3.2 on Access to Nonlocal Objects). (5 pts)

Answers

The program prints 3, 2. A's static link points to B, which points to main, allowing A to access g.

a) The program prints the following integers: 3, 2.

b) The stack and its activation records, with the static links, can be shown as follows:

     |          |

    |    g     |   <-- main's activation record

    |___static_|

    |          |

    |    a     |   <-- B's activation record

    |    x     |

    |___static_|

    |          |

    |    n     |   <-- A's activation record

    |___static_|

c) A can access the nonlocal object g through the chain of static links that connect its activation record to the activation record of the subroutine that directly contains the declaration of g. In this case, the static link in A's activation record points to the activation record of B, because B is the subroutine that directly contains the declaration of g. B's activation record, in turn, has a static link that points to the activation record of main, which is the subroutine that declares g. Therefore, when A refers to g, it follows the static links to access the correct instance of g.

Learn more about program :

https://brainly.com/question/11023419

#SPJ4

t/f lysergic acid diethylamide (lsd) is proven to cure migraine headaches when used in prescribed doses.

Answers

Lysergic acid diethylamide (lsd) is proven to cure migraine headaches when used in prescribed doses.

The statement is False.

Lysergic acid diethylamide (LSD) has been studied for its potential therapeutic uses, there is currently no conclusive evidence to support its effectiveness in treating migraine headaches.

In fact, the use of LSD for medical purposes is highly controversial and not approved by regulatory agencies such as the FDA. LSD can have significant side effects and risks, and should only be used under the guidance of a medical professional in a research or therapeutic setting.

The use of LSD is highly controversial, as it can produce significant and unpredictable side effects, including hallucinations, paranoia, and psychotic symptoms.

Learn more about Lysergic acid diethylamide here:

brainly.com/question/10107492

#SPJ4

1) In a single statement, declare and initialize a reference variable called mySeats for an ArrayList of Seat objects.
2) Add a new element of type Seat to an ArrayList called trainSeats.
3) Use method chaining to get the element at index 0 in ArrayList trainSeats and make a reservation for John Smith, who paid $44.
SeatReservation.java
import java.util.ArrayList;
import java.util.Scanner;
public class SeatReservation {
/*** Methods for ArrayList of Seat objects ***/
public static void makeSeatsEmpty(ArrayList seats) {
int i;
for (i = 0; i < seats.size(); ++i) {
seats.get(i).makeEmpty();
}
}
public static void printSeats(ArrayList seats) {
int i;
for (i = 0; i < seats.size(); ++i) {
System.out.print(i + ": ");
seats.get(i).print();
}
}
public static void addSeats(ArrayList seats, int numSeats) {
int i;
for (i = 0; i < numSeats; ++i) {
seats.add(new Seat());
}
}
/*** End methods for ArrayList of Seat objects ***/
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String usrInput;
String firstName, lastName;
int amountPaid;
int seatNumber;
Seat newSeat;
ArrayList allSeats = new ArrayList();
usrInput = "";
// Add 5 seat objects to ArrayList
addSeats(allSeats, 5);
// Make all seats empty
makeSeatsEmpty(allSeats);
while (!usrInput.equals("q")) {
System.out.println();
System.out.println("Enter command (p/r/q): ");
usrInput = scnr.next();
if (usrInput.equals("p")) { // Print seats
printSeats(allSeats);
}
else if (usrInput.equals("r")) { // Reserve seat
System.out.println("Enter seat num: ");
seatNumber = scnr.nextInt();
if ( !(allSeats.get(seatNumber).isEmpty()) ) {
System.out.println("Seat not empty.");
}
else {
System.out.println("Enter first name: ");
firstName = scnr.next();
System.out.println("Enter last name: ");
lastName = scnr.next();
System.out.println("Enter amount paid: ");
amountPaid = scnr.nextInt();
newSeat = new Seat(); // Create new Seat object
newSeat.reserve(firstName, lastName, amountPaid); // Set fields
allSeats.set(seatNumber, newSeat); // Add new object to ArrayList
System.out.println("Completed.");
}
}
// FIXME: Add option to delete reservations
else if (usrInput.equals("q")) { // Quit
System.out.println("Quitting.");
}
else {
System.out.println("Invalid command.");
}
}
}
}
Seat.java:
public class Seat {
private String firstName;
private String lastName;
private int amountPaid;
// Method to initialize Seat fields
public void reserve(String resFirstName, String resLastName, int resAmountPaid) {
firstName = resFirstName;
lastName = resLastName;
amountPaid = resAmountPaid;
}
// Method to empty a Seat
public void makeEmpty() {
firstName = "empty";
lastName = "empty";
amountPaid = 0;
}
// Method to check if Seat is empty
public boolean isEmpty() {
return (firstName.equals("empty"));
}
// Method to print Seat fields
public void print() {
System.out.print(firstName + " ");
System.out.print(lastName + " ");
System.out.println("Paid: " + amountPaid);
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public int getAmountPaid() {
return amountPaid;
}
}

Answers

Answer:

ArrayList<Seat> mySeats = new ArrayList<>();

trainSeats.add(new Seat());

trainSeats.get(0).reserve("John", "Smith", 44);

Explanation:

ArrayList<Seat> mySeats = new ArrayList<>();

This declares a reference variable called mySeats for an ArrayList of Seat objects and initializes it as an empty list.

trainSeats.add(new Seat());

This adds a new element of type Seat to an ArrayList called trainSeats. The new Seat object is created using the default constructor.

trainSeats.get(0).reserve("John", "Smith", 44);

This uses method chaining to get the element at index 0 in ArrayList trainSeats and call the reserve method on it with arguments "John", "Smith", and 44. This makes a reservation for John Smith, who paid $44.

looking at the following, which answer best shows the software characteristics that are used to determine the scope of a software project?

Answers

The answer "Context, information objectives, function and performance" best shows the software characteristics that are used to determine the scope of a software project.

These characteristics help to define the boundaries and requirements of the software project. Context refers to the environment in which the software will be used, including the hardware, software, and other systems it will interact with. Information objectives describe what the software is intended to accomplish and the information it will process. Function defines the features and capabilities of the software, while performance outlines the speed and efficiency requirements of the software. All of these characteristics are important in determining the scope of a software project and ensuring that it meets the needs of its users.

Learn more about software :

https://brainly.com/question/1022352

#SPJ4

assign variable largestval with the largest value of 9 positive floating-point values read from input. ex: if the input is 4.2 15.3 16.9 18.3 17.2 11.6 14.1 7.7 14.9, then the output is: 18.3 note: the first value read is the largest value seen so far. all floating-point values are of type double.

Answers

This program reads in 9 double values from the user via standard input, and it assigns the first value to the variable largestval. It then loops through the remaining 8 values and checks each one to see if it's larger than largestval. If it is, then it updates the value of largestval. Finally, it prints the largest value that was read in.

What is an example of largestval?

Here's an example solution in Java:

java

Copy code

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {

   Scanner scanner = new Scanner(System.in);

   double largestval = scanner.nextDouble();

   for (int i = 1; i < 9; i++) {

     double val = scanner.nextDouble();

     if (val > largestval) {

       largestval = val;

     }

   }

   System.out.println(largestval);

 }

}

To know more about largestval, Check out:

https://brainly.com/question/28895168

#SPJ1

.

Code written in C to determine how long it takes for a population to reach a particular size from gathering user input 'start', 'end', and the program outputting the number of years it will take (based on the pre-set birth and death rate) for the 'start' to reach the 'end' population number.
Say we have a population of n llamas. Each year, n / 3 new llamas are born, and n / 4 llamas pass away.
Complete the implementation of population.c, such that it calculates the number of years required for the population to grow from the start size to the end size.
Your program should first prompt the user for a starting population size.
If the user enters a number less than 9 (the minimum allowed population size), the user should be re-prompted to enter a starting population size until they enter a number that is greater than or equal to 9. (If we start with fewer than 9 llamas, the population of llamas will quickly become stagnant!)
Your program should then prompt the user for an ending population size.
If the user enters a number less than the starting population size, the user should be re-prompted to enter an ending population size until they enter a number that is greater than or equal to the starting population size. (After all, we want the population of llamas to grow!)
Your program should then calculate the (integer) number of years required for the population to reach at least the size of the end value.
Finally, your program should print the number of years required for the llama population to reach that end size, as by printing to the terminal Years: n, where n is the number of years.
Example Tests: $ ./population Start size: 1200 End size: 1300 Years: 1
Example Tests: $ ./population Start size: -5 Start size: 3 Start size: 9 End size: 5 End size: 18 Years: 8

Answers

C program enters a loop which simulates population growth over time. Each loop's iteration updates population based on birth and death rates and increments years. Loop continues until the population is greater than or equal to final population size.

How to write a program in C for implementing population to calculate the number of years it takes for the population to grow from its initial size to its final size?

#include <stdio.h>

int main(void)

{

   int start, end, population, years = 0;

   printf("Enter a starting population size (minimum 9): ");

   scanf("%d", &population);

   while (population < 9) {

       printf("Population size must be at least 9. Try again: ");

       scanf("%d", &population);

   }

   printf("Enter an ending population size: ");

   scanf("%d", &end);

   while (end < population) {

       printf("Ending population must be greater than or equal to starting population. Try again: ");

       scanf("%d", &end);

   }

   while (population < end) {

       population += population / 3 - population / 4;

       years++;

   }

   printf("Years: %d\n", years);

   return 0;

}

Program prints (output) number of years until population reached its final size. 

To learn more about Writing a program in C visit:

https://brainly.com/question/7344518

#SPJ4

write an algorithm using flowchart and pseudocode, which
inputs a whole number (which is >0)
calculates the number of digits in the number
outputs the number of digits and the original number

Answers

Write a pseudocode and draw a flowchart solution, which will take in an integer value from the user and determine whether that value is odd or even.

What is algorithm?

"A set of finite rules or instructions to be followed in calculations or other issue-solving procedures" or "A process for solving a mathematical problem in a finite number of steps that typically contains recursive operations" are two definitions of the word algorithm.

An algorithm is a set of guidelines for resolving a dilemma or carrying out a task. A recipe, which consists of detailed directions for creating a dish or meal, is a typical illustration of an algorithm.

Machine learning algorithms can be classified into four categories: supervised, semi-supervised, unsupervised, and reinforcement learning.

Algorithms are procedures for resolving issues or carrying out tasks. Algorithms include math equations and recipes. Algorithms are used in programming. All online searching is done using algorithms, which power the internet.

Read more about algorithm:

https://brainly.com/question/24953880

#SPJ1

What are the goals of checking and rechecking the quality of your data during data validation?

Answers

During data validation, it's important to double-check your data's quality to make sure it's dependable, accurate, comprehensive, and consistent.

You can find and fix any flaws or discrepancies in your data by completing thorough data validation, which contributes to improving the precision and dependability of your analysis and outcomes. As a result, decisions may be made with greater clarity and provide results that are more successful. Validating your data can also help to ensure that it complies with all applicable legal and regulatory requirements, helping you avoid costly errors or penalties. You can make sure that your data is current and dependable throughout time by routinely reviewing and revising it.

learn more about Data validation here:

brainly.com/question/29033397

#SPJ4

Scenario
You are the manager of a software development team working on new applications for your company, Optimum Way Development, Inc. Your director has called for all development teams to submit product briefs detailing their current projects. The director plans to share the most promising product briefs with clients at an upcoming meeting. You have software design documents for two potential projects.
Directions
You must choose one of the potential products and use the information contained in the technical specification document to create your product brief. The brief is intended to explain the new application to potential clients. (Use the personas created for the 2-1 Milestone as the audience for this project.) You should highlight the features that will appeal to clients and persuade them to purchase the new application. Your brief should include the following:
An explanation of the features and functions of the product
Clear definitions of technical terms and concepts that are relevant to communicating the product capabilities
An explanation of the benefits of using the product within an organization
Graphics that support or clarify technical information concerning the product
Appropriate language for the intended audience
What to Submit
To complete this project, you must submit the following:
Product Brief with Graphics
This assignment must be 500 to 1,000 words in length and should include at least two graphics that help clarify technical concepts. Any references must be cited in APA format.
Supporting Materials
The following resource(s) may help support your work on the project:
Resource: Software Design Documents
Use one of these software design documents as the basis for your product brief.
Website: Webopedia
This website gives definitions of several technology terms. You can use this website to assist with defining terminology in the software design documents.
Website: What Is a Product Brief and Why Is It Important?
This website explains the components of a product brief and why it is important. Although you do not need to follow the suggested suggestions exactly, this may act as a starting point for structuring your assignment.
Shapiro Library Resource: APA Style
This Shapiro Library guide goes over the basics of APA-style formatting and citations.

Answers

You have two possible projects' software design documents. Definitions of technical phrases and ideas that are pertinent to describing the capabilities of the product.

A software development language, is C++?

C++ is a strong-typed, quick programming language that is a great option for creating operating systems.C++ is also used in the majority of Microsoft's software, including Windows, Microsoft Office, the IDE Visual Studio, and Browser.

Is a career in software development difficult?

Despite having a lot of potential, the breadth and complexity of the software development industry make it difficult to learn. A strong understanding of a variety of programming languages, operating systems, database systems, and other areas is required of software developers.

To know more about  software development visit:

https://brainly.com/question/20318471

#SPJ4

The binary number 1010101 converted to decimal is__________. Enter the answer.O 85O 90O 72O 11

Answers

Answer:85

Explanation:

In Binary, we have 8 bits, all powers of 2, going up to 128.

When you only have 7 digits, you just add 0's to the left until it's 8. So in this case it would 01010101. Each 0 means the bit is "off," and each 1 means the bit is "on."

The 1st bit, from left to right, equals 128. The next is 64, then 32, then 16, then 8, then 4, then 2, then 1.

Since this specific number is alternating between bits, we know it is:

64 + 16 + 4 + 1 = 85

Since these are the bits that are turned on. Hope this helps!

A single query that excludes the result of a subquery returns the same result as two queries joined by the except operator when the second query matches the excluded subquery in the current release of MySQL (8.0.21).TrueFalse

Answers

False. A single query that excludes the result of a subquery returns the same result as two queries joined by the except operator when the second query matches the excluded subquery in the current release of MySQL (8.0.21).

What is single query?

A single query only contains one SELECT statement, whereas a compound query may contain two or more SELECT statements. By using a specific operator to join the two queries, compound queries can be created. In the examples that follow, two queries are joined together using the UNION operator.

The command most frequently used in Structured Query Language is the SELECT statement. Access to records from one or more database tables and views is made possible by using it. Additionally, it retrieves the data that has been chosen and meets our requirements.

We can also access a specific record from a specific table column by using this command. A result-set table is the one that contains the record that the SELECT statement returned.

Learn more about single query

https://brainly.com/question/30031969

#SPJ4

Write a statement that assigns treeHeight with the height of a tree given the distance from the tree (in feet) and angle of elevation (in degrees).Use the following formula: tangent of angle Elevation tree Height/ tree Distance tree Height

Answers

Math. tan (angle Elevation) is a built-in Java mathematical function used to calculate the tangent of a number, and the return result is always double. Double tree Height = (Math. tan (angle Elevation) * tree Distance.

What in Java is Math tan ()?

Trigonometric tangent of an angle is returned by tan().If the argument is NaN or infinite, the result is returned as NaN. If the argument is zero, the result has the same sign as the argument and is a zero.

What are the five approaches to teaching math?

Lecture, inductive, deductive, heuristic or discovery, analytic, synthetic, problem-solving, laboratory, and project approaches are some of the ways that math is taught. Any approach may be used by teachers depending on the particular unit of the curriculum.

To know more about Java visit:-

https://brainly.com/question/29897053

#SPJ4

An application lists all the files and subdirectories in its web folder. This indicates which of the following weaknesses on the application?
a. Directory Listing
b. Cross Site Scripting
c. Session Hijacking

Answers

Directory Listing is the correct response. The web folder of an application contains a list of all the files and subdirectories. This reveals application flaws with Directory Listing.

a subfolder is a computerised organisational directory that is nested inside another directory. Sections of your main website can be divided using subdirectories, which are content subfolders. Each subfolder shares the top-level domain (TLD) of your website, and its URL structure always follows the root domain. Examples of subdirectories include all of the following: example.com/shop. The subdirectory appears in a URL after the root directory or domain name.  Therefore, hubspot.com/pricing might be a subfolder URL. Alternatively, it may be something more challenging like pricing/sales.hubspot.com. Typically, a single subdirectory within this tree structure is referred to as a directory or subdirectory, respectively.

Learn more about subdirectories here:

https://brainly.com/question/29360568

#SPJ4

Other Questions
Which molecules are bound to hemoglobin when hemoglobin is in the R state? CO2,3-bisphosphoglycerate Fel2+ oxygen Fe+ What does drive reduction theory mean in psychology? Using Models The moon in its orbit aroundEarth behaves like a ball at the end of a stringbeing swung above your head. Explain theforces involved. What is a entertainer personality? Li Marie's water tables are evenly spaced along the 5,000-meter (or 5-kilometer) course, including one at the beginning and one at the end. What is the distance between each pair of tables that are next to each other? Hint: There are not 9 sections between tables. What is four functions in management How do you find eigenvalues and eigenvectors on a calculator? Include one paragraph to explain the movement of energy during phase transitions.(solid, liquid gas)just a quick 4 or 5 sentences about the 3 states of matter you wrote yourself please(i dpnt care how detailed it is) Describe thetransfer ofenergy as itmoves up theenergy pyramid. can you give dogs imodium The answer in order Which of the following shows a correct method to calculate the surface area of the cylinder?cylinder with diameter labeled 3.2 feet and height labeled 3.8 feet SA = 2(1.6)2 + 3.2(3.8) square feet SA = 2(1.6)2 + 1.6(3.8) square feet SA = 2(3.2)2 + 3.2(3.8) square feet SA = 2(3.2)2 + 1.6(3.8) square feet Story of a warrior queen discussion Identify one form of propaganda from the story that you felt was successful. Explain why you felt this was successful. Im without this type of question, exploration is never started _____. in terms of the function s, the limit we would have to evaluate in order to calculate the slope of the tangent line to s at t=1 is If Coffee And Creamer Are Complementary Goods, Then An Increase In The Price Of Creamer, Other Things Being Equal, Will Result In A) A Decrease In The Demand For Creamer B) An Increase In The Demand For Sugar C) A Decrease In The Demand For Coffee D) An Increase In The Quantity Demanded Of Creamer fill in the blank. suppose the equilibrium price for basketballs is $23. if every store prices their basketballs at $21, this would lead to a___and would put pressure on prices. The presidents military powers are strictly limited to foreign wars and not domestic unrest Where's Philip?Philip is not here. Hea presentation. Givingis givinggives What is the ICD-10 code for pneumonia due to infectious organism?