1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ivanzaharov [21]
3 years ago
6

What is the problem with the code snippet below? public class Test { public static void main(String[] args) { System.out.println

(cost(10, 4)); } public static void cost(int price, int reps) { for (int i = 0; i < reps; i++) { System.out.print(price); } } }
Computers and Technology
1 answer:
FrozenT [24]3 years ago
6 0

Answer:

The problem in the following snippet is that the function "cost" returns the void and it cannot used as the expression in the print statement

Explanation:

public class Test

{

    public static void main(String[] args)

    {

          System.out.println(cost(10, 4));

     }

     public static void cost(int price, int reps)

     {

           for (int i = 0; i < reps; i++)  

           {

                   System.out.print(price);                

           }  

     }

}

Output:

Main.java:4: error: 'void' type not allowed here

        System.out.println(cost(10, 4));

                               ^

1 error

In the following code the void type is not allowed in the function "cost".

You might be interested in
A _______ is the most commonly used input device.
nirvana33 [79]
The answer is B.Keyboard
4 0
3 years ago
Read 2 more answers
. What is an "anti-pattern"?
Fed [463]

Explanation:

Anti - pattern -

Anti-pattern are the software development design patterns that are considered bad programming practices .

For example , an anti-pattern designing might involve making a god object which performs multiple functionalities, and the better design pattern would be to separate out each function into different objects.

5 0
4 years ago
You are configuring a firewall to use NAT. In the configuration, you map a private IP address directly to a persistent public IP
Ivan

Answer:

Option B (Static NAT) would be the correct choice.

Explanation:

  • Static NAT seems to be a method of NAT methodology used to navigate as well as monitor internet usage from some kind of specific public IP address to something like a private IP address.
  • Everything always allows the provision of web access to technology, repositories including network equipment inside a protected LAN with an unauthorized IP address.

Some other decisions made aren't relevant to the situation in question. So the above alternative is indeed the right one.

8 0
3 years ago
The underline format will underline ____.
alisha [4.7K]
<span>The underline format will underline </span>the selected text
7 0
3 years ago
Write an app that reads an integer, then determines and displays whether the integer is odd or even. [Hint: Use the remainder op
Sholpan [36]

Answer:

#include <stdio.h>// header file

int main() // main function definition

{

   int number; // variable declaration

   scanf("%d",&number); // user input for number

   if(number%2==0) // check the number to even.

   printf("Number is a even number"); // print the message for true value

   else

   printf("Number is a odd number"); // print the message for false value.

   return 0; // return statement.

}

Output:

  • If the user inputs is 2 then the output is "Number is a even number".
  • If the user inputs is 3 then the output is "Number is a odd number".

Explanation:

  • The above program is to check the even and odd number.
  • The first line of the program is used to include the header file which helps to understand the functions used in the program.
  • Then there is the main function that starts the execution of the program.
  • Then there is a variable declaration of number which is declared as an integer which takes the integer value because the program needs the integer only.
  • Then the scanf function is used to take the inputs from the user.
  • Then the if condition check that the number is divisible by 2 or not.
  • If it is divisible print "even number" otherwise print "odd-number".
8 0
4 years ago
Other questions:
  • A Windows systems administrator should use the Administrator account ________.a. As little as possible, and only when needed b.
    15·1 answer
  • An executive at an online video company wants to look over usage data from the previous month. The company has data from
    15·2 answers
  • What is the output, if userVal is 5? int x; x = 100; if (userVal != 0) { int tmpVal; tmpVal = x / userVal; System.out.print(tmpV
    14·1 answer
  • The Internet has made going global easier than it has ever been, but the promise of "borderless commerce" remains restrained bec
    12·1 answer
  • Why are computers assigned IP addresses?
    11·1 answer
  • Which spreadsheet toolbar displays options such as Cut and Paste?
    11·2 answers
  • Professor Gig A. Byte needs to store text made up of the characters A with frequency 6, B with frequency 2, C with frequency 3,
    10·1 answer
  • Cual es la relacion existe entre TENGNOLOGIA y la PRODUCCION DE ENERGIA
    8·1 answer
  • Which of the following statements about content-based filtering is TRUE?
    9·1 answer
  • Describe the differences and similarities between the most common operating systems used for Mac, PC, and Linux in
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!