how could this code be simplified?

Answers

Answer 1

The code to be simplified is not indicated but I will give you a general guide to simplifying Java codes.

How do you simplify Java Code?

At the top, declare and initialize your variables. Late declaration disrupts readability.Create specific functions that are modular. It is inefficient to have functions that attempt to "do it all". Make it a practice to name the function to correspond to the task.All duplications must be removed and rectifiedHaving comments provide a fantastic way to summarize the purpose of a code.Do not overuse recursion. Doing this makes it difficult to understand at a glance.If possible, do not use global variables. The local variable takes precedence over the global variable in JavaScript.

Learn more about Java code at;
https://brainly.com/question/18554491
#SPJ1


Related Questions

5.18 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one. Ex: If the input is: 5 2 4 6 8 10 the output is: 10,8,6,4,2, To achieve the above, first read the integers into a vector. Then output the vector in reverse.

Answers

Answer:

In C++:

#include<iostream>

#include<vector>

using namespace std;

int main(){

   int len, num;

   vector<int> vect;

   cout<<"Length: ";

   cin>>len;  

   for(int i = 0; i<len;i++){

       cin>>num;

   vect.push_back(num);}

   vector<int>::iterator iter;

   for (iter = vect.end() - 1; iter >= vect.begin(); iter--){

       cout << *iter << ", ";}    

}

Explanation:

This declares the length of vector and input number as integer

   int len, num;

This declares an integer vector

   vector<int> vect;

This prompts the user for length  

cout<<"Length: ";

This gets the input for length  

   cin>>len;  

The following iteration gets input into the vector

   for(int i = 0; i<len;i++){

       cin>>num;

   vect.push_back(num);}

This declares an iterator for the vector

   vector<int>::iterator iter;

The following iterates from the end to the beginning and prints the vector in reverse

   for (iter = vect.end() - 1; iter >= vect.begin(); iter--){

       cout << *iter << ", ";}

1. It is a set of integrated devices that input, output,
process, and store data and information.
a. Computer hardware
b. Computer software
c. Computer system
d. Computer program​

Answers

A set of integrated devices that input, output, process, and store data and information is called: C. Computer system.

What is a computer system?

A computer system can be defined as an electronic device that is designed and developed to receive data in its raw form as input and processes these data into an output (information) that could be used by an end user.

The components of a computer.

Basically, the components of a computer system are classified as follows:

MotherboardCentral processing unit (CPU)Output Input

Read more on computer system here: brainly.com/question/959479

Which of the following would be considered software? Select 2 options.
memory
printer
operating system
central processing unit (CPU)
Microsoft Office suite (Word, Excel, PowerPoint, etc.)
Thing

Answers

Answer:

Microsoft Office suite (Word, Excel, PowerPoint, etc.), and thing

Explanation:

The Operating system and Microsoft Office suite will be considered as software.

A Software is the opposite of Hardware in a computer system.

Let understand that Software means some set of instructions or programs on a computer which are used for operation and execution of specific tasks.

There are different type of software and they include:

Application Software are software installed into the system to perform function on the computer E.g. Chrome.System Software is the software designed to provide platform for other software installed on the computer. Eg. Microsoft OS. Firmware refers to set of instructions programmed on a hardware device such as External CD Rom.

In conclusion, the Operating system is a system software while the Microsoft Office suite is an application software.

Learn more about Software here

brainly.com/question/1022352

Define a class named Money that stores a monetary amount. The class should have two private integer variables, one to store the number of dollars and another to store the number of cents. Add accessor and mutator functions to read and set both member variables. Add another function that returns the monetary amount as a double. Write a program that tests all of your functions with at least two different Money objects.

Answers

Answer:

#include<iostream>

using namespace std;

class Money{

    private:

        int dollars;  

       int cents;

   public:

       Money(int d=0, int c=0){

          setDollar(d);

          setCent(c);

       }

       void setDollar(int d){

           dollars = d;

       }

       void setCent(int c){

           cents = c

       }

       int getDollar() {

           return dollars;

       }

       int getCent() {

           return cents;

       }

       double getMoney(){

          return (dollars + (cents/100));

       }

};

// testing the program.

int main(){

  Money Acc1(3,50);

  cout << M.getMoney() << endl;

  Money Acc2;

  Acc2.setDollars(20);

  Acc2.setCents(30);

  cout <<"$" << Acc2.getDollars() << "." << Acc2.getCents() << endl;

  return 0;

}

Explanation:

The C++ source code defines the Money class and its methods, the class is used in the main function as a test to create the instances of the money class Acc1 and Acc2.

The object Acc2 is mutated and displayed with the "setDollar and setCent" and "getDollar and getCent" methods respectively.

it is an electronic device that capable of accessing accepting processing product and storing data​

Answers

"A computer is an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program." "A computer is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data."

You should write the client so that it sends 10 ping requests to the server, separated by approximately one second. Each message contains a payload of data that includes the keyword PING, a sequence number, and a timestamp. After sending each packet, the client waits up to one second to receive a reply. If one second goes by without a reply from the server, then the client assumes that its packet or the server's reply packet has been lost in the network.Hint: Cut and paste PingServer, rename the code PingClient, and then modify the code. The two programs follow very similar process.You should write the client so that it starts with the following command:java PingClient host portwhere host is the name of the computer the server is running on and port is the port number it is listening to. Note that you can run the client and server either on different machines or on the same machine.The client should send 10 pings to the server. Because UDP is an unreliable protocol, some of the packets sent to the server may be lost, or some of the packets sent from server to client may be lost. For this reason, the client cannot wait indefinitely for a reply to a ping message. You should have the client wait up to one second for a reply; if no reply is received, then the client should assume that the packet was lost during transmission across the network. You will need to research the API for DatagramSocket to find out how to set the timeout value on a datagram socket.When developing your code, you should run the ping server on your machine, and test your client by sending packets to localhost (or, 127.0.0.1). After you have fully debugged your code, you should see how your application communicates across the network with a ping server run by another member of the class.Message FormatThe ping messages in this lab are formatted in a simple way. Each message contains a sequence of characters terminated by a carriage return character (r) and a line feed character (n). The message contains the following string:PING sequence_number time CRLFwhere sequence_number starts at 0 and progresses to 9 for each successive ping message sent by the client, time is the time when the client sent the message, and CRLF represent the carriage return and line feed characters that terminate the line.

Answers

Answer:

figure it out urself

Explanation:

Your friend really likes talking about owls. Write a function owl_count that takes a block of text and counts how many words they say have word “owl” in them. Any word with “owl” in it should count, so “owls,” “owlette,” and “howl” should all count.

Here’s what an example run of your program might look like:

text = "I really like owls. Did you know that an owl's eyes are more than twice as big as the eyes of other birds of comparable weight? And that when an owl partially closes its eyes during the day, it is just blocking out light? Sometimes I wish I could be an owl."
owl_count(text)
# => 4
Hints

You will need to use the split method!


Here is what I have so far, it doesn not like count = 0 and i keep getting an error.
def owl_count(text):

count = 0

word = 'owl'

text = text.lower()

owlist = list(text.split())

count = text.count(word)


text = "I really like owls. Did you know that an owl's eyes are more than twice as big as the eyes of other birds of comparable weight? And that when an owl partially closes its eyes during the day, it is just blocking out light? Sometimes I wish I could be an owl."
print (count)

Answers

text = “ I really like owls. Did you know that an owls eyes are more than twice as big as the eyes of other birds of comparable weight? And that when an owl partially closes its eyes during the day, it is just blocking out light? Sometimes I wish I could be an owl.

word = ‘owl’
texts = text.lower()
owlist = list(texts.split())
count = text.count(word)
num = [owlist, count] #num has no meaning just random var
print(num)


Alter in anyway you want so that you can succeed. ✌

In this exercise we have to use the knowledge of computational language in python, so we find the code like:

The code can be found attached.

So let's write a code that will be a recognition function, like this:

def owl_count(text):"I really like owls. Did you know that an owls eyes are more than twice as big as the eyes of other birds of comparable weight?"

word = "owl"

texts = text.lower()

owlist = list(texts.split())

count = text.count(word)

num = [owlist, count] #num has no meaning just random var

print(num)

See more about python at brainly.com/question/26104476

Difference between a port and a connector

Answers

Explanation:

A connector is the unique end of a plug, jack, or the edge of a card that connects into a port. Port: The port has either holes or a slot that matches the plug or card being connected into the port. For example: cables are plugged into Ethernet ports, and cables and flash drives are plugged into USB ports.

You are going on vacation and want to take some work files. You need a storage device that is small enough to fit in your bag and preferably one that does not have plugs. Which device should you bring?


hard drive bus

flash drive

external hard drive

storage card

Answers

Answer:

Flash drive

Explanation:

25 POINTS PLATO
Drag the tiles to the boxes to form correct pairs.
Pat creates a table in a spreadsheet program, starting at cell A1 and ending at cell B4. Column A contains words, while column B contains the words’ meanings. Pat wants to look up the meaning of the word "paramount", which is present in cell A3. How should Pat write the LOOKUP function? Refer to the syntax of the function and match the arguments in the syntax to their values.

Syntax: LOOKUP(lookup value; search table; result table)

B1:B4
"paramount"
A1:A4

lookup value
search table
result table

Answers

Answer:

lookup value   =  "paramount"

Search table   =  A1:A4

Result table     =  B1;B4

Explanation:

lookup, what are we looking up.....:::///????Paramount

What is the beginning search table......A1;A4

Column B contains the words meanings.....this is the result we want:

So the Result table......B1:B4

LOOKUP("paramount"; B1:B4; A1:A4)  should Pat write the LOOKUP function.

What is a LOOKUP function?

Lookup functions entail accessing a cell, comparing its values to those in an adjacent row or column, and then extracting the relevant answers from the associated columns or rows of Excel.

The lookup value, the search table, and indeed the result table are the three inputs required by the LOOKUP function. The value you are searching for, in this case, "paramount," is the lookup value.

The table that contains the lookup value, throughout this example B1:B4, is known as the search table.

The table where the results of the lookup are stored is known as the result table, and in this example, A1:

Pat should use the columns which would have the cell value of B1, B4 as well as A1.

Learn more about the LOOKUP function, here:

https://brainly.com/question/29517410

#SPJ3

what is the file extension if the file editing​

Answers

Explanation:

"A file extension (or simply "extension") is the suffix at the end of a filename that indicates what type of file it is. For example, in the filename "myreport. txt," the . TXT is the file extension.Sometimes long file extensions are used to more clearly identify the file type."


In the central processing unit (CPU).
A) Causes data to be input into the system
B) Responsible for the logical order of processing and converting data.
C) Both
D) None of the above

Answers

Answer : B.responsible for the logical order of processing and converting daya

Reason

As i said bro, in CPU there are ALU and CU where ALU is to do mathematics problem and CU where its to processing, converting data. CPU is like the brain of computer. But it can't be the input, the input can get through hardware, not CPU.


When you
you can use the diverse knowledge sets of a team and share a workload.
O strategize
O quantify
discriminate
I
O collaborate

Answers

Answer:

Collaborate.

Explanation:

It was correct for me!

Answer:collaborate

Explanation:

cs edgen 100%

How is QA done in agile projects

Answers

200+300-500.

Explanation:

rjfnvkfjfhfofgfohgighghgiggh

Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/kmâpick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a function drive that simulates driving the car for a certain distance, reducing the fuel level in the gas tank, and functions get_gas, to return the current fuel level, and add_gas, to tank up. Sample usage:Car my_beemer(29); // 29 miles per gallonmy_beemer.add_gas(20); // Tank 20 gallonsmy_beemer.drive(100); // Drive 100 milescout << my_beemer.get_gas() << "\n"; // Print fuel remaining

Answers

Answer:

class Car(object):

   fuel = 0

   def __init__(self, mpg):

       self.mpg = mpg

   def drive(self, mile):

       if self.fuel * self.mpg >= mile:

           self.fuel -= mile / self.mpg

       else:

           print(f"get gas for your {self}")

       print(f"Fuel remaining: {self.fuel}")

   #classmethod

   def get_gas(cls):

       cls.fuel += 50

   #classmethod

   def add_gas(cls, gallon):

       if cls.fuel + gallon > 50:

           cls.fuel += 10

       else:

           cls.fuel += gallon

gulf = Car(20)

gulf.get_gas()

gulf.drive(200)

Explanation:

The Car class is defined in Python. Its drive method simulates the driving of a car with fuel that reduces by the miles covered, with efficiency in miles per gallon. The get_gas and add_gas methods fill and top up the car tank respectively.

The math club starts with 5 members. Five months later, their membership has grown to 50 members.
What was the average number of members who joined the math club per month?​

Answers

Explanation:

10 members per month i think

Answer:

10 members per month

Explanation:

brainliest pls its right i think

have a good day :D

What is Open Source Software​

Answers

Answer:

Open-source software is a type of computer software in which source code is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software to anyone and for any purpose

Explanation:

3/4+7=
what is the answer​

Answers

Answer:

7 3/4

Explanation:

3

4

+ 7

=  (0 + 7) + (  

3

4

+ 0 )

=  7 +  

3

4

+ 0 × 4

=  7 +  

3

4

+  

0

4

=  7 +  

3 + 0

4

=  7 +  

3

4

=  

7 3

4

identify similarities and differences of hibiscus leaves

Answers

Answer:

I'm sorry but I cant answer if it's only one product,it should be two..it's like different to what,or similar to what

Convert (24) 10 to binary​

Answers

Answer:

Decimal 24 to Binary Conversion

The base-10 value of 24 10 is equal to base-2 value of 110002.

I hope it's helpful!

Answer:

The binary of 24 is 11000

Companies sometimes pay search engine companies to have their websites located at the top of the search results. Do you think this is fair/ethical?

Answers

Answer:

I really don't think that it is fair or ethical.

Explanation:

When companies pay to put their websites at the top it is known as an ad. They are in top search engines like the ones we use every day. I believe this is unethical because it often results in confusion and sometimes misleads the user as the titles often use clickbait.

Write a program that computes how much each person in a group needs to pay (after tax and tip) when splitting the bill equally. Specifically, your program should: 1. Ask a user for the number of people in the party 2. Ask a user for the total bill amount before tax and tip 3. Output the amount due per person after tax and tip Assume that tax is 7.25%, and tip is 20% (tip is before tax).

Answers

Tax is an incredibly weird thing but I wish I could help but I can’t

What is computer science​

Answers

Answer:

computer science is the study of computer and computing as well as theoretical and practical applications.

pls give me thanks ☺️☺️

Checkpoint 4.20 Assume hour is an int variable. Write an if statement that displays the message “Time for lunch” only if hour is equal to 12.

Answers

Answer:

if(hour == 12)

{cout << "Time for lunch";}

Explanation:

Which situations are the most likely to use telehealth? Select 3 options.

Your doctor emails a suggested diet plan.

Your brother was tested for strep throat and now you think you have it.

Your doctor invites you to use the patient portal to view test results.

You broke your arm and need a cast

You request an appointment to see your doctor using your health app.

Answers

Answer:

Your doctor emails a suggested diet plan.

Your brother was tested for strep throat and now you think you have it.

Your doctor invites you to use the patient portal to view test results.

Answer:

Your doctor emails a suggested diet plan

You request an appointment to see your doctor using your health app

Your doctor invites you to use the patient portal to view test results

Explanation:

Edge 2022

lower cabinet is suitable for storing and stocking pots and pans true or false​

Answers

True.
Make sure cabinet is clean enough to put the pots and pans.

What happens when two users attempt to edit a shared presentation in the cloud simultaneously? The second user is unable to open the presentation. When the second user logs on, the first user is locked out. A presentation cannot be shared in the cloud for this reason. A warning notice will alert the users that the presentation is in use.

Answers

Answer:

a warning notice will alert the users that the presentation is in use

Explanation:

I did it on edge

Answer:

D; A warning notice will alert the users that the presentation is in use.

Explanation:

Edge

How to write an algorithm to read and print a name?
I want the steps please

Answers

Answer:

Step 1: Obtain a description of the problem. This step is much more difficult than it appears. ...

Step 2: Analyze the problem. ...

Step 3: Develop a high-level algorithm. ...

Step 4: Refine the algorithm by adding more detail. ...

Step 5: Review the algorithm.

Explanation:

Save an image as a separate file by right-clicking the image and then clicking this option at the
shortcut menu
A) Save page as
B) Save Picture as
C) Save Image as
D) None of the above

Answers

Answer:

Save image as

Explanation:

Save image as. Because you are saving the image.

apples and bananas apples and bananas

Answers

Answer:

bananas and apples bananas and apples?

Explanation:

Answer:

these are good for me

Explanation:

yeye

Other Questions
Solve the system of equations using subtraction.3x - 2y = 53x + y = 11 A food worker needs to cool a large batch of tuna casserole Find the quotient1. 2292 5= 2. 3+ 27 +3= Solving quadratics equations by square root method In a study of all 3813 students at a college, it is found that 45% own a vehicle. Is this a statistic or parameter? Your teacher is giving a test that has 5 more four-point questions than six-point questions. The test is worth 120 points. Which system represents this information? A car travels 208 miles in 3 hours and 15 minutes. How many miles does it travel per hour? please help me ASAP thank you What describes the conversion of ADP to ATP? please help me guys! HELP!! THIS IS FOR SPANISH!!Change the adjective to match the subject 1:los hermanos son (altos)2:la made es (cubano)3:las abuelas son (bajo) What I need to know about Hungary? HELP REEEEEEEEEEEEEEEEEEEEEEEEE Find the area of the figure. PLEASE HELP Find the number of terms and the degree of this polynomial. B. Fill in the blanks :1. Women are paid__________for doing the same work as compared to men.2. Gender inequality is a__________problem which afflicts our country today.3. Raja Ram Mohan Roy was the first__________ to take the lead in the direction of social reform.4. Women have been subjected to________humiliation and__________.5. The National Commision for Women was set up in January___________. Which text feature could the author add to "Georgia O'Keeffe: Modernist Pioneer" to help readers better understand and visualize O'Keeffe's work?a chart that shows how much her paintings costa chart that shows which materials she usedan image of one of her flower paintingsan image of the artist with her husband plz im timed Text structure is defined asthe major theme of a text.the number of paragraphs in a text.the way information is arranged in a text.the sentence length used in a text. 1/3(9x + 12) = 15a. x=5b. x=3.67c. x=2.8d. x=4.5 If f(7) = 22, thenf^-1(22) = [?]