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
Edhesive 11.1 lesson practice please
zloy xaker [14]

Answer:

1. Bits

2. Bitrate

3. The amount of time it takes for bits to travel from one place to another.

4. Used to send bits wirelessly.

5. Cables that carry light and dramatically increase the speed and accuracy of information over the internet.

6. 8

7. The number of bits per second a system can transmit.

Explanation:

hey lol

3 0
3 years ago
Samuel was hired to create a program that asks the user questions and, based on the answers, recommend a book to read. What kind
quester [9]

Answer:

I think the answer is C

Explanation:

Selection

3 0
3 years ago
Which is true of effective passwords?
mylen [45]

Answer:

It is either A. or D.

4 0
3 years ago
Elsa wants to save her work at the office to be continued at home either on a pen drive or CD. Outline three reasons why she wil
Solnce55 [7]

Answer:

Pen Drive offers more accessibility

Not every device is equipped with a CD player but every device has a USB port for a pen Drive. Saving on the pen Drive will therefore enable the data to be more accessible.

Pen Drive has more space.

CDs usually have a storage capacity of below a gigabyte whilst pen drives can reach up to 2 terabytes thereby offering exponentially more space to save data.

Safety of Data

CDs are more prone to damage as data could be lost if the CD is scratches. Pen Drives on the other hand are encased in an outer case that protects the data.

5 0
3 years ago
What operating system good for 3d modeler
Brrunno [24]

Answer:

If you're looking for a distribution to use for 3D work, we would recommend trying either CentOS or Ubuntu, in second place. It can be installed on any PC computer that is able to run windows, and can even dual boot. It can not, however run windows or mac applications.

Explanation:

<h3>I hope this helps!</h3>
5 0
3 years ago
Read 2 more answers
Other questions:
  • How do I connect my CSS file and HTML page together? it's just not wanting to work for me. 
    5·1 answer
  • Who is the CEO of Quora?
    15·1 answer
  • A patient presents at an outpatient urgent care facility with an acute illness and is seen by a provider. A detailed history wit
    13·1 answer
  • To print data sideways on a piece of paper, use the _______ page orientation setting.
    6·2 answers
  • What's the drawback of using Screened Subnet (DMZ)?
    12·1 answer
  • 19. The power supply in your server has just been replaced because of power problems. Your server boots, but now there is a mess
    13·1 answer
  • How are computers 35 years ago and how are they presently and how are they going to be in the next 35 years
    9·1 answer
  • Which of the following statements are true about file naming conventions? Check all of the boxes that apply.
    7·2 answers
  • Someone help me out eh?
    10·2 answers
  • If two devices simultaneously transmit data on an Ethernet network and a collision occurs, what does each station do in an attem
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!