Create an application named ArithmeticMethods whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayNumberPlus10(), displayNumberPlus100(), and displayNumberPlus1000(). Create each method to perform the task its name implies. Save the application as ArithmeticMethods.java.

Answers

Answer 1
Answer:

Answer:

public class ArithmeticMethods

{

public static void main(String[] args) {

    int number1 = 7;

    int number2 = 28;

 displayNumberPlus10(number1);

 displayNumberPlus10(number2);

 displayNumberPlus100(number1);

 displayNumberPlus100(number2);

 displayNumberPlus1000(number1);

 displayNumberPlus1000(number2);

}

public static void displayNumberPlus10(int number){

    System.out.println(number + 10);

}

public static void displayNumberPlus100(int number){

    System.out.println(number + 100);

}

public static void displayNumberPlus1000(int number){

    System.out.println(number + 1000);

}

}

Explanation:

Inside the main:

Initialize two integers, number1 and number2

Call the methods with each integer

Create a method called displayNumberPlus10() that displays the sum of the given number and 10

Create a method called displayNumberPlus100() that displays the sum of the given number and 100

Create a method called displayNumberPlus1000() that displays the sum of the given number and 1000


Related Questions

Why we need each section of prologprogram?
What is the largest safety threat to the ISS?Will give brainlest :)
Select the true statement(s) regarding a virtual circuit. a. both analog and digital networks take advantage of the virtual circuit concept b. virtual circuits require the assignment of dedicated physical links during network connection c. regarding the efficient use of physical links, virtual circuits are more efficient than analog circuits d. both a and b are true statements"
Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists (2, 5, 5, 5) and (2, 2, 3, 5, 5, 7), the output should be (2, 5, 5).
your manager ask you to set up a secure network connection at a remote site which protocol would you use

Question textIf operator+ is supported by a class, how many parameters should it be defined to accept?

Select one:

a. 1 or 2

b. 2

c. 3

d. 1

e. None

Answers

Answer:

b. 2

Explanation:

As we know operator + is supported by the class.Since we know that the + operator binary operator means it needs two operands to work upon it cannot work on one operand.++ operator is unary operator it works on one operand only.

For example:-

a+b

a++.

Hence we conclude that the answer is 2.

Mai has recently created her own e-mail account. Her father gave her permission to e-mail her friends and family but warned her that it is dangerous to open e-mails from people she does not know. Mai did not understand why her father would give her this warning. Why did Mai’s father say it is dangerous to open e-mails from unknown senders? Check all that apply. The sender could be a hacker. The e-mail could be inappropriate. The e-mails usually contain jokes. The e-mail may belong to someone else The message may contain a virus.

Answers

Answer:A,B,E

Explanation:

Because I just took the quiz

Answer:

I think the last 1 or the 2nd one

Explanation:sorry if im wrong TwT

10. Blender® allows users to duplicate an object simply by selecting it and pressing duplicate on the toolbar (shift+D). (1 point)true

false



11. According to the unit, which of the following is an important first step in any creative endeavor? (1 point)

pre-production

post-planning

delegating tasks

sending emails

Answers

10. Blender® allows users to duplicate an object simply by selecting it and pressing duplicate on the toolbar (shift+D).
True

11. According to the unit, which of the following is an important first step in any creative endeavor?
pre-production

Hope this helps.

Write a program that reads the contents of a text file. The program should then create a structure that has 3 fields: a word, the frequency of the word, the list of line numbers where the word appears. Then the program will open a text file and read the content of the file. It will create another text file as output file. The output file should contain an alphabetical listing of the words, their frequency, and the list of line numbers where the word appears. -g

Answers

Answer:

See explaination

Explanation:

#include <iostream>

#include <fstream>

#include <string>

#include <vector>

#include <map>

#include <sstream>

using namespace std;

// structure to hold the word, frequency and list of lines in which word appears

struct wordFrequency

{

string word;

int frequency;

vector<int> lineNumber;

};

// main method

int main()

{

// input file name. You can change the input file name if your file name is different

string inputFileName = "data.txt";

// creating a map class object to hold words uniquely

map<string, wordFrequency> map_word;

// ifstream class object to open and read from file

ifstream fin(inputFileName);

// validating if file is opened or not

if (!fin.is_open())

{

cout << "Error in opening file!";

exit(1);

}

// string to hold line from file

string line;

// int variable to keep track of line number

int lineNumber = 0;

// fetching lines from file

while (getline(fin, line))

{

// increasing the lineNumber count because we fetch another line

++lineNumber;

// breaking a line into words using stringstream class object

string word;

stringstream iss(line);

// iterating over all the words in a line

while (iss >> word)

{

// if the word is not in the map then we create and add a new pair

auto it = map_word.find(word);

if (it == map_word.end())

{

// creating a new struct object to store new word

wordFrequency w;

w.word = word;

w.frequency = 1;

w.lineNumber.push_back(lineNumber);

map_word.insert({word, w});

}

else

{

// if the word is already there then incresing frequency and push line number into list

it->second.frequency += 1;

it->second.lineNumber.push_back(lineNumber);

}

}

}

// closing the input file

fin.close();

// creating a new output file

ofstream fout("WordFrequency.txt");

if (fout.is_open())

{

// iterating over a map

for (auto word : map_word)

{

// writing data to a output file

fout << "Word is : " << word.second.word << endl;

fout << "Frequency is : " << word.second.frequency << endl;

fout << "Appears in line : ";

for (auto i : word.second.lineNumber)

{

fout << i << " ";

}

fout << endl

<< endl;

}

// closing output file

fout.close();

}

else

{

cout << "Error! Not able to create output file!";

}

}

Consider the following functions: (4) int hidden(int num1, int num2) { if (num1 > 20) num1 = num2 / 10; else if (num2 > 20) num2 = num1 / 20; else return num1 - num2; return num1 * num2; } int compute(int one, int two) { int secret = one; for (int i = one + 1; i <= two % 2; i++) secret = secret + i * i; return secret; } What is the output of each of the following program segments? a. cout << hidden(15, 10) << endl; b. cout << compute(3, 9) << endl; c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl; d. x = 2; y = 8; cout << compute(y, x) << endl;

Answers

Answer:

a.  cout<<hidden(15,10)<<endl;

output = 5

b. cout << compute(3, 9) << endl;

output=3

c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl;

output = 10

d. x = 2; y = 8; cout << compute(y, x) << endl;

output= 8

Explanation:

solution a:

num1= 15;

num2= 10;

according to condition 1, num1 is not greater than 20. In condition 2, num2 is also not greater than 20.

so,

the solution is

return num1 - num2 = 15 - 10 = 5

So the output for the above function is 5.

solution b:

as in function there are two  integer type variables named as one and two. values of variables in given part are:

one = 3

two = 9

secret = one = 3

for (int i= one + 1 = 3+1 = 4; i<=9%2=1; i++ )

9%2 mean find the remainder for 9 dividing by 2 that is 1.

//  there 4 is not less than equal to  1 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 3;

so answer return from the function is 3.

solution c:

As variables in first function are num1 and num2. the values given in part c are:

num1 = 30;

num2= 20;

According to first condition num1=30>20, So,

num1= num2/10

so the solution is

num1 = 20/10 = 2

now

num1=2

now the value return from function Hidden is,

return num1*num2 = 2* 20 = 40

Now use the value return from function hidden in function compute as

compute(10, hidden(30, 20))

as the value return from hidden(30, 20) = 40

so, compute function becomes

compute(10, 40)

Now variable in compute function are named as one and two, so the values are

one= 10;

two = 40;

as

secret = one

so

secret = 10;

for (int i= one + 1 = 10+1 = 11; i<=40%2=0; i++ )

40%2 mean find the remainder for 40 dividing by 2 that is 0.

//  there 11 is not less than equal to  0 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 10;

so answer return from the function is 10.

solution d:

Now variable in compute function are named as one and two, so the values are

one = y = 8

two = x = 2

There

Secret = one = 8;

So

for (int i= one + 1 = 8+1 = 9; i<=2%2=0; i++ )

2%2 mean find the remainder for 2 dividing by 2 that is 0.

//  there 9 is not less than equal to  0 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 8;

so answer return from the function is 8.

A cybersecurity analyst is currently investigating a server outage. The analyst has discovered the following value was entered for the username: 0xbfff601a. Which of the following attacks may be occurring?(A) Buffer overflow attack
(B) Man-in-the-middle attack
(C) Smurf attack
(D) Format string attack
(E) Denial of service attack

Answers

Answer:D)Format string attack

Explanation:

Format string attack is the type of attack that causes to change the application functioning .This attack access the memory of the string library. It occurs while the submission of the string as input and then gets tested due to application command.

Other options are incorrect because these are the attacks that don't happens in the application for the alteration of the flow. Thus, the correct option is option(D).

Other Questions